• 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: Strategy for acting on changes in child objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strategy for acting on changes in child objects?


  • Subject: Re: Strategy for acting on changes in child objects?
  • From: Seth Willits <email@hidden>
  • Date: Thu, 7 May 2009 18:21:16 -0700

On May 7, 2009, at 5:31 PM, Graham Cox wrote:

The problem I have with it is that I can't precisely tell from the documentation what problem it solves, and whether it is the same problem that I've had in the past (and Seth has now) which I solved as outlined. It seems to solve a closely related but slightly different problem, but I'm not sure. My inability to get it to work reflects my lack of a complete understanding of what it does.

Maybe you could point me to some supplementary documentation (external to Apple's if necessary) that explains it in a bit more detail?


The best example I've seen is the one in the docs.

If you have Person class with -firstName -setFirstName: -lastName - setLastName: and -fullName, implementing kPFVAVFK allows you to automatically trigger changes for the key "fullName" whenever firstName or lastName changes.


+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
{
NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];


if ([key isEqualToString:@"fullName"])
{
NSSet *affectingKeys = [NSSet setWithObjects:@"lastName", @"firstName",nil];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
}
return keyPaths;
}



It doesn't directly solve the problem like ours, but is tangentially related.




The 10.4 method is similar: setKeys:triggerChangeNotificationsForDependentKey:. You'd just call it with the keys firstName and lastName forDependentKey:fullName.

The KVO programming guide goes into the real differences between the two, but in the simplest case, that's all it is and they're pretty equivalent.


-- Seth Willits



_______________________________________________

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


References: 
 >Re: Strategy for acting on changes in child objects? (From: Caleb Strockbine <email@hidden>)
 >Re: Strategy for acting on changes in child objects? (From: Graham Cox <email@hidden>)
 >Re: Strategy for acting on changes in child objects? (From: Shawn Erickson <email@hidden>)
 >Re: Strategy for acting on changes in child objects? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Strategy for acting on changes in child objects?
  • Next by Date: Re: losing focus momentarily, over and over again
  • Previous by thread: Re: Strategy for acting on changes in child objects?
  • Next by thread: Re: Strategy for acting on changes in child objects?
  • Index(es):
    • Date
    • Thread