Re: addObserver:forKeyPath:options:context
Re: addObserver:forKeyPath:options:context
- Subject: Re: addObserver:forKeyPath:options:context
- From: Herbert Putteneers <email@hidden>
- Date: Tue, 18 Apr 2006 10:08:59 +0200
I 'm not sure sure if this would be a good solution for large/heavily
modified sets, but I once
added a dummy "isDirty" attribute to my class and
in the initialize method of this class set it to generate change
notifications for isDirty when any of the attributes I am really
interested in changes;
[self setKeys:[NSArray arrayWithObjects:@"_frameColor",
@"_frameTransparency", @"_fillColor", @"_fillTransparency",
@"_captionColor", @"_captionTransparency", @"_captionPosition", nil]
triggerChangeNotificationsForDependentKey:@"_attribsChanged"];
Now I only have to watch one "isDirty" attribute per instance.
Regards,
Herbert Putteneers
On 17 apr 2006, at 20:02, Eric Long wrote:
Hi,
I have a master/detail interface that is working well overall with
bindings.
I have an array of objects the user can edit individually. I want
to know
when the user has changed an object's value so I can enable my "Save
Changes" button.
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.
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.
What's the right way to do this?
Thanks,
Eric
_______________________________________________
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
_______________________________________________
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