Re: Use of KVC Array operators
Re: Use of KVC Array operators
- Subject: Re: Use of KVC Array operators
- From: Eli Bach <email@hidden>
- Date: Fri, 12 Mar 2010 12:19:34 -0700
On Mar 12, 2010, at 9:58 AM, Alexander Spohr wrote:
>> 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?
That it wouldn't do this merging of set's automatically.
And I did just try it, and got a binding error:
Cocoa Bindings: Error setting value for bound property instanceOfA of object <controllerclass: 0x100675780>: [<_NSFaultingMutableSet 0x1006eab90> addObserver:forKeyPath:options:context:] is not supported. Key path: relationC
I figured it would be something like this, which is why I was looking at the @unionOfSets operator in particular (as that's exactly what this is, a union of all sets of relationC objects from a set of relationB objects.
Eli
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden