Am 12.03.2010 um 17:32 schrieb Eli Bach: > On Mar 12, 2010, at 5:37 AM, Alexander Spohr wrote: > >> Am 12.03.2010 um 04:34 schrieb Eli Bach: >> >>> The operators mentioned on this page, particularly "@unionOfSets". >>> >>> <http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html> >>> >>> I have the following Core Data object's setup >>> >>> ClassA ClassB ClassC >>> relationA --> relationB --> relation C >>> >>> where each of the relations is a many to one [one class A, many class B, >>> and one class B, many class C]. >>> Not all ClassB's will have ClassC objects attached to them >>> >>> I have an instance of classA, and I want an NSArrayController with all the >>> ClassC objects for all the ClassB objects that are related to that specific >>> instance of ClassA, preferably in a way that uses KVO instead of >>> programmatically updating with fetches/predicates/etc. >>> >>> What would be the right way to bind the NSArrayController, assuming the nib >>> owner has an instance of classA: >> >> How about Owner.instanceOfA.relationB.relationC ? >> If you ask an array for a key path you get a new array containing the >> resulting objects. >> You don’t need any operators. > > I'll try this, but I don't expect it to work, because there can be 0 or more > relationB object's, and each of those object's can have 0 or more relationC > objects, and just 'plain' dot syntax won't produce a superset of relationC > objects
If you have 0 Bs, you’ll have an empty array If you have Bs without Cs they just wont fill anything into the array. *methinks* it might be that you get some NSNull in there for the empty Cs. But no, this should not happen because the relationship itself is an NSSet, not a pointer that can be nil. From NSSet’s valueForKey: Discussion The returned set might not have the same number of members as the receiver. The returned set will not contain any elements corresponding to instances of valueForKey: returning nil (note that this is in contrast with NSArray’s implementation, which may put NSNull values in the arrays it returns). valueForKeyPath: is just a recursive or iterative call: "Discussion The default implementation gets the destination object for each relationship using valueForKey: and returns the result of a valueForKey: message to the final object." atze > (from my understanding of KVO and KVC). what is your understanding of KVC? _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com