• 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
Core Data to-many relationships and keyPathsForValuesAffectingValueForKey
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data to-many relationships and keyPathsForValuesAffectingValueForKey


  • Subject: Core Data to-many relationships and keyPathsForValuesAffectingValueForKey
  • From: email@hidden
  • Date: Fri, 23 Nov 2007 11:48:37 +0100

Hi,

I have set up a Core Data model with two entities, Account and Operation.
Account has a to-many relationship With Operation named operations.
Operation has an attribute amount and Account has a property total (not in the
model) which is supposed to be the sum of the amount of all its operations.

I would like to trigger a KVO notification for the key total of an account
whenever the amount of one of its operations changes.

I know in 10.4 it wasn't ever possible as the method
setKeys:triggerChangeNotificationsForDependentKey: didn't work with keyPaths but
I suppose I should be able to do it in 10.5 with
keyPathsForValuesAffectingValueForKey.

I implemented method keyPathsForValuesAffectingValueForKey in Account.m as
follows :
- (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
   NSMutableSet *keyPaths = [NSMutableSet setWithSet:[super
keyPathsForValuesAffectingValueForKey:key]];
   if ([key isEqualToString:@"total"]) {
      [keyPaths addObject:@"operations.amount"];
   }
   return keyPaths;
}

When trying to run my program, I get an error saying that _NSFaultingMutableSet
is not KVO compliant with key "amount".

So, how am I supposed to do this ?

Thanks,
Cyril Anger
_______________________________________________

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: Core Data to-many relationships and keyPathsForValuesAffectingValueForKey
      • From: "Sean McBride" <email@hidden>
  • Prev by Date: PSContent HTML retrieval
  • Next by Date: Re: Writing optimized screeshot utility.
  • Previous by thread: PSContent HTML retrieval
  • Next by thread: Re: Core Data to-many relationships and keyPathsForValuesAffectingValueForKey
  • Index(es):
    • Date
    • Thread