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

Re: Core Data to-many relationships and keyPathsForValuesAffectingValueForKey


  • Subject: Re: Core Data to-many relationships and keyPathsForValuesAffectingValueForKey
  • From: "Sean McBride" <email@hidden>
  • Date: Fri, 23 Nov 2007 12:29:06 -0500
  • Organization: Rogue Research

On 11/23/07 11:48 AM, email@hidden said:

>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".

I have also switched my code to use this new
keyPathsForValuesAffectingValueForKey method.  I have not been able to
make it work with key paths either.  I don't get the error you do, since
I'm not using Core Data.  It just silently fails.  My code is slightly
different (I don't always create a new set), but I doubt that accounts
for it.  Anyway, here's how I do it:

+ (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key
{
	NSSet* set = [super keyPathsForValuesAffectingValueForKey:key];
	if ([key isEqualToString:@"overallStatus"]) {
		set = [set setByAddingObjectsFromSet:[NSSet setWithObjects:
			@"subStatus1", @"subStatus2",
   @"someController.subStatus3", (id)nil]];
	}
	return set;
}

It works for subStatus1 and 2, but not 3.

Anyone have working keyPathsForValuesAffectingValueForKey sample code?

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________

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: 
 >Core Data to-many relationships and keyPathsForValuesAffectingValueForKey (From: email@hidden)

  • Prev by Date: Re: -[NSManagedObjectContext save:] fails but gives no NSError
  • Next by Date: Re: Problem with WithBindings sample code?
  • Previous by thread: Core Data to-many relationships and keyPathsForValuesAffectingValueForKey
  • Next by thread: With What does Apple Swizzle the IsA-pointer in KVO?
  • Index(es):
    • Date
    • Thread