Re: Easy question about bindings for a custom view
Re: Easy question about bindings for a custom view
- Subject: Re: Easy question about bindings for a custom view
- From: Kyle Sluder <email@hidden>
- Date: Thu, 19 Mar 2009 20:19:14 -0400
2009/3/19 Ulai Beekam <email@hidden>:
> One more question: If I set my custom view to be an observer for employeesArray with the keyPath "selectedObjects", my custom view indeed does get an observeValueForKeyPath: message whenever the employeesArray selection changes. Observing "selectedObjects" like this is exactly what I should be using, right? Getting confirmation on that would be great.
Yes, but you'll also need to observe the interesting attribute on each
of the model objects contained in selectedObjects. Otherwise you
won't know when any of the objects themselves change; you'll only be
told when the collection changes (e.g., when something is added to or
removed from the collection).
> However, I also notice that if I do the following in the observeValueForKeyPath method:
>
> id newAttribute = [changeDict objectForKey:NSKeyValueChangeNewKey];
> NSLog(@"%@", [newAttribute className]);
>
> what gets printed is, alas, NSNull! Is this the very same bug you spoke about? Getting confirmation on that as well will tell me that I understood your message properly. And yes, just to make it clear, I did set NSKeyValueObservingOptionNew when registering as the observer :)
Yes, this is the bug I mentioned. As you observe model objects, you
will need to add them to an array, and stop observing objects as they
are removed from and start observing when they are added to the array
controller's selection.
--Kyle Sluder
_______________________________________________
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