Re: addObserver:forKeyPath:options:context
Re: addObserver:forKeyPath:options:context
- Subject: Re: addObserver:forKeyPath:options:context
- From: mmalcolm crawford <email@hidden>
- Date: Mon, 17 Apr 2006 11:46:20 -0700
On Apr 17, 2006, at 11:02 AM, Eric Long wrote:
I don't understand how to use the
addObserver:forKeyPath:options:context to
allow my UI controller to observe when a property of any object in my
objects array has changed. There's no key path I can watch for the
array,
since array items are referenced by index. It seems kind of
ridiculous to
iterate the array and register individually for each object. I'm
thinking
there must be a better way to do this.
No, there isn't -- using KVO...
I want to know when the user has changed an object's value so I can
enable my "Save Changes" button.
How else are you tracking changes? Are you using an undo manager?
I'd imagine that you would have a more coarse-level indication that
there are unsaved edits? (You presumably have a means of identifying
that there are *no* changes to be saved?)
I haven't been able to find sample code that shows a master/detail
implementation that detects changes to the data that must be saved.
Because conceptually it's an orthogonal problem. For an example of
observing all the properties of all objects in an array, see <http://
homepage.mac.com/mmalc/CocoaExamples/controllers.html> (Graphics
Bindings).
mmalc
_______________________________________________
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