• 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: George Orthwein <email@hidden>
  • Date: Sat, 15 Jul 2006 01:36:10 -0400

Hi Matt,
Yeah I'm actually doing something similar though I wasn't aware of NSSelectorFromString.


For a custom view that responds to a few dozen attributes of the controller's current selection....

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
NSString *keyPathName;
if ([keyPath isEqualToString:@"selection.bgImage.color"] == YES){
// handle special case of this attribute of a relationship
keyPathName = @"bgImageColor";
} else {
// convert "selection.attribute" keypath to appropriate accessor name -- by abusing pathExtension method :)
keyPathName = [keyPath pathExtension];
}
[self setValue:[object valueForKeyPath:keyPath] forKey:keyPathName];
}


So observing "selection.attribute" will call my setAttribute accessor with the new value via KVC.

Possibly not the most proper setup, but it seems to work well enough for this view's situation.

George

_______________________________________________
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>)

  • Prev by Date: Re: Question about method names in NSKeyedArchiver
  • Next by Date: Re: Detecting Internet
  • Previous by thread: KVO and the observeValueForKeyPath bottleneck
  • Next by thread: Re: KVO and the observeValueForKeyPath bottleneck
  • Index(es):
    • Date
    • Thread