Getting modified object in observeValueForKeyPath:ofObject:change:context: for non-simple key paths
Getting modified object in observeValueForKeyPath:ofObject:change:context: for non-simple key paths
- Subject: Getting modified object in observeValueForKeyPath:ofObject:change:context: for non-simple key paths
- From: "Mike R. Manzano" <email@hidden>
- Date: Wed, 28 Nov 2007 11:25:57 -0800
Hi all,
I'd like to get notifications when a particular property of any object
in a to-many relationship changes. Right now, I do that by observing
the key path "arrangedObjects.serviceURL" on an NSArrayController.
This does indeed notify me when any of the serviceURL properties
change. However, I can't seem to figure out how to get the specific
object in the array whose property was changed from the arguments
passed in observeValueForKeyPath:...
I did manage to get the object by going directly to the
NSArrayController and asking it for its selection, but it seems a bit
hackish to do so (i.e., does Cocoa guaranteed that the selection will
always be set correctly when observeValueForKeyPath:... is called?)
Is there a proper work-around pattern for this?
Another related question, what if I'm binding to an object that
doesn't have a concept of selection? For example, if I wanted to bind
to NSManagedContext's -registeredObjects (I actually haven't tried
this yet, but will in a moment).
Thanks,
Mike
_______________________________________________
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