I'm exploring Core Data & I'm running into some difficulty with relationships binding. I have a simple model of an address book created with the design tool & using the default classes. There are two entities:
Person name - attribute addresses - relationship to-Many Address (inverse of Person)
Address street - attribute city - attribute state - attribute person - relationship to-One Person (inverse of addresses)
In IB, I dragged the entities to create a basic interface & chose many objects for each entity. I left the default names of all controllers & then I created a text field that I want to display the number of addresses for a given Person. I bound it to the Person Array Controller, using a Controller Key of selection, and a model key of addresses.@count. I was thinking that this should take the currently selected Person, get their addresses & display a count of how many there were. When I start adding addresses, I get an exception:
[<NSManagedObject 0x3a5380> addObserver:<NSArrayController 0x570d500> forKeyPath:@"addresses.@count" options:0x0 context:0x0] was sent to an object that is not KVC-compliant for the "addresses" property.]
In looking thru the docs, it appears that relationship properties would naturally return an NSSet. I tried varying the binding to use addresses.count (count being a valid method name in NSSet), but still no joy. Is it possible to do what I want with the basic NSManagedObject instead of subclassing to create an addressCount method?
Thanks for your help,
Niels |