Re: Core Data Relationship Binding
Re: Core Data Relationship Binding
- Subject: Re: Core Data Relationship Binding
- From: Niels Meersschaert <email@hidden>
- Date: Thu, 2 Jun 2005 19:05:28 -0400
JT,
Thanks for the feedback. Unfortunately, the text field I was trying to connect it to was set to be NOT editable (source was the label text field) & @count works fine for Core Data Attributes in the test. The distinction that I was running into was if the property was a Relationship to the entity, like addresses, standard operator bindings don't work. The workaround is to subclass NSManagedObject & implement the count method, but that seems to defeat a lot of the value of the bindings/Core Data functionality. My guess is that the @operators only work on NSArrays, while a relationship property returns a NSSet.
Niels On Jun 2, 2005, at 6:35 PM, John Timmer wrote: 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? Unfortunately, as your error noted, the count property is not key/value coding compliant, since you can’t set the count, only read it. As such, you can’t bind an editable value to the count of a set or array. I know that for basic text fields, binding to a displayPattern with keys like @count works nicely. Whether it would work for the value of the text field, I’m not sure. I also haven’t tried setting a table column as non-editable and checked if bindings work in that context. JT _______________________________________________ This mind intentionally left blank |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden