Re: KVO and the observeValueForKeyPath bottleneck
Re: KVO and the observeValueForKeyPath bottleneck
- Subject: Re: KVO and the observeValueForKeyPath bottleneck
- From: Jakob Olesen <email@hidden>
- Date: Mon, 17 Jul 2006 13:03:19 +0200
On 17/07/2006, at 12.38, Jakob Olesen wrote:
- (void)awakeFromNib
{
[myController addObserver:self forKeyPath:@"selectedObjects"
options:0 context:@selector(selectionChanged:)];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
object change:(NSDictionary *)change context:(void *)context
{
if ([self respondsToSelector:(SEL)context])
[self performSelector:(SEL)context withObject:change];
}
Sorry to follow up on myself, but it just occurred to me that the
information fits perfectly in an NSNotification:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
object change:(NSDictionary *)change context:(void *)context
{
[self performSelector:(SEL)context withObject:[NSNotification
notificationWithName:keyPath object:object userInfo:change]];
}
The method you dispatch to is then identical to a notification
handler. (You could even use it for both in simple cases)
_______________________________________________
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