• 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
tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:


  • Subject: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:
  • From: Chris Idou <email@hidden>
  • Date: Wed, 15 Oct 2008 17:16:40 -0700 (PDT)

For one of my attributes I can't seem to get keyPathsForValuesAffecting<Key> to do its thing. The following is my code. I'm observing both keys to try and find out what's going on. keyPathsForValuesAffectingCanLink does get called. observeValueForKeyPath gets called for key noteController.linkableSelection, but it never gets called for "canLink".

Shouldn't the existance of keyPathsForValuesAffectingCanLink mean that every time the observer gets triggered for noteController.linkableSelection that it also gets triggered for canLink? Is there any circumstances it wouldn't? Tearing my hair out!



+ (NSSet *)keyPathsForValuesAffectingCanLink {
return [NSSet setWithObject:@"noteController.linkableSelection"];
}

- (void)awakeFromNib {
[self addObserver:self
   forKeyPath:@"noteController.linkableSelection"
   options:NSKeyValueObservingOptionNew
   context:NULL];
[self addObserver:self
   forKeyPath:@"canLink"
   options:NSKeyValueObservingOptionNew
   context:NULL];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
  change:(NSDictionary *)change
  context:(void *)context {
 NSLog(@"oVFKP: %@", keyPath);
}

Now, I can fake it by replacing the above function with this, and this works:

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
  change:(NSDictionary *)change
  context:(void *)context {
  if ([keyPath isEqualToString:@"noteController.linkableSelection"]) {
     [self willChangeValueForKey:@"canLink"];
     [self didChangeValueForKey:@"canLink"];
  }
 NSLog(@"oVFKP: %@", keyPath);
}

But this is obviously not ideal since I'm doing the job that keyPathsForValuesAffectingCanLink is supposed to be doing.











_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:
      • From: Ken Thomases <email@hidden>
References: 
 >Re: +(NSSet *)keyPathsForValuesAffectingValueForKey: (From: "Ashley Clark" <email@hidden>)

  • Prev by Date: Re: -[NSMutableSet addObject:] Ambiguous Docs: -isEqual: vs. ==
  • Next by Date: Objective-C parameter mutation
  • Previous by thread: Re: +(NSSet *)keyPathsForValuesAffectingValueForKey:
  • Next by thread: Re: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:
  • Index(es):
    • Date
    • Thread