FROM : Sean McBride
DATE : Fri Nov 23 18:29:06 2007
On 11/23/07 11:48 AM, <email_removed> 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_removed>
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
DATE : Fri Nov 23 18:29:06 2007
On 11/23/07 11:48 AM, <email_removed> 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_removed>
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
| Related mails | Author | Date |
|---|---|---|
| angeman7 | Nov 23, 11:48 | |
| Sean McBride | Nov 23, 18:29 |






Cocoa mail archive

