Projects

Ticket #152 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

KVC arguments not properly marshalled

Reported by: ben@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.4
Component: MacRuby Keywords:
Cc: ben@…

Description

An argument isn’t being marshalled properly to mutable array KVC accessors.

class KVCTest
  def initialize; @a = []; end
  def countOfThings; @a.size; end
  def objectInThingsAtIndex(i); @a[i]; end
end
KVCTest.new.valueForKey 'things'

irb(main):015:0> KVCTest.new.valueForKey 'things'
TypeError: no implicit conversion from nil to integer
	from (irb):11:in `[]'
	from (irb):11:in `objectInThingsAtIndex'
	from bin/irb:12:in `<main>'

Not sure why objectInThingsAtIndex: is getting a nil arg here.

Change History

Changed 3 years ago by ben@…

  • cc ben@… added

Cc Me!

Changed 3 years ago by ben@…

This is really a method signature issue.

Changed 3 years ago by ben@…

Here’s the proposal from Rich:

kvo do
  def countOfThings; 42; end
  def objectInThingsAtIndex(i); "The Answer"; end
end

Changed 3 years ago by ben@…

  • status changed from new to closed
  • resolution set to fixed

Fixed in r720 and r721.

Changed 3 years ago by ben@…

  • milestone set to MacRuby 0.4

Changed 3 years ago by ben@…

  • status changed from closed to reopened
  • resolution fixed deleted

Fixed key names in r743.

Changed 3 years ago by ben@…

  • status changed from reopened to closed
  • resolution set to fixed

For posterity, the final syntax is:

class MathFacts
  kvo_array :firstTenSquares do
    def size; 10; end
    def [](i); (i+1)*(i+1); end
  end
end

>> MathFacts.new.valueForKey 'firstTenSquares'
=> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

and similar for kvo_set.

Note: See TracTickets for help on using tickets.