Re: addObserver:forKeyPath:options:context
Re: addObserver:forKeyPath:options:context
- Subject: Re: addObserver:forKeyPath:options:context
- From: Eric Long <email@hidden>
- Date: Tue, 18 Apr 2006 09:43:17 -0700
> 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"];
Yeah, I'm kind of wondering what the overhead on this gets to be like when
you have a few thousand items.
In my case, I decided to set my +/- actions to call my methods, which then
call the NSArrayController methods for adding/removing. So I see it happen
and can set isDirty. I also use the controlTextDidChange() delegate methods
so I see edits and can follow those changes. Seems a lot less expensive and
it works for my case.
Someone else mentioned an NSArray(KeyValueObserving) method:
addObserver:toObjectsAtIndexes:forKeyPath:options:context:
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