Ticket #122 (closed defect: fixed)
error in objects initialized with an options hash and KVO (maybe a caching issue in dispatcher)
| Reported by: | rich@… | Owned by: | lsansonetti@… |
|---|---|---|---|
| Priority: | blocker | Milestone: | MacRuby 0.3 |
| Component: | MacRuby | Keywords: | |
| Cc: |
Description
The following code should work:
framework 'cocoa'
class Foo
attr_accessor :subject, :key, :another_key
def initialize(subject, options={})
@subject = subject
@key = options[:key]
@another_key = options[:another_key]
end
end
def objects
[Foo.new("test", :key => 'key', :another_key => 'another_key'), Foo.new("test2", :key => 'key2', :another_key => 'another_key2')]
end
controller = NSArrayController.alloc.init
controller.addObjects(objects)
controller.setAvoidsEmptySelection(true)
controller.setPreservesSelection(false)
controller.setSelectsInsertedObjects(false)
controller.setAutomaticallyRearrangesObjects(true)
controller.setSortDescriptors([NSSortDescriptor.alloc.initWithKey("subject", ascending: true)])
If instead you place a single item it works:
def objects
[Foo.new("test", :key => 'key', :another_key => 'another_key')]
end
Or if you make the second item have a different set of keys...
def objects
[Foo.new("test", :key => 'key', :another_key => 'another_key'), Foo.new("test2", :another_key => 'another_key')]
end
This it works again...
Change History
Note: See
TracTickets for help on using
tickets.

