• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: KVO and the observeValueForKeyPath bottleneck
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >KVO and the observeValueForKeyPath bottleneck (From: Matt Neuburg <email@hidden>)
 >Re: KVO and the observeValueForKeyPath bottleneck (From: Jakob Olesen <email@hidden>)

  • Prev by Date: Re: KVO and the observeValueForKeyPath bottleneck
  • Next by Date: Re: Drag and drop... without moving mouse?
  • Previous by thread: Re: KVO and the observeValueForKeyPath bottleneck
  • Next by thread: Re: KVO and the observeValueForKeyPath bottleneck
  • Index(es):
    • Date
    • Thread