Skip navigation.
 
mlBindings: Changes dependent on keypaths
FROM : Allen Smith
DATE : Mon Aug 14 20:34:11 2006

I have a class whose data is mostly packaged into an 
NSMutableDictionary:

@interface Controller : NSObject
{
   NSMutableDictionary *dialogData;
}

Then my controls' values are bound to the data in the dictionary 
using keypaths such as "dialogData.value". Now I want to bind another 
control to a method in the Controller class whose return value is 
partially derived from data in the dictionary. Conceptually, I want 
to do the following:

@implementation Controller

+ (void) initialize
{
   //this does not work!
   [self setKeys:[NSArray arrayWithObject:@"dialogData.value"]
         triggerChangeNotificationsForDependentKey:@"pictogram"];
}


- (NSImage *) pictogram
{
   if( [[dialogData objectForKey:@"value"] isEqual:foo] )
       return bar;
   else
       return baz;
}

@end


Observing keypaths doesn't work like this. So what am I supposed to 
do instead? (Note: my dependent key result might be built from 
multiple values in the dictionary, so a value transformer could get a 
little goofy here.)

Related mailsAuthorDate
No related mails found.