key value observing and binding
key value observing and binding
- Subject: key value observing and binding
- From: Francisco Tolmasky <email@hidden>
- Date: Fri, 2 Jan 2004 03:16:48 -0800
Before I changed my class, I was able to use
setKeys:triggerChangeNotificationsForDependentKey:
to associate three keys with another. Yet, I then changed my class to
instead of having three instance variables to store these values in an
NSMutableDictionary, as so:
before:
NSString *one, *two, *three;
after:
NSMutableDictionary *values;
Yet, I would still like to make it so that when I say [values
setObject: whatever forKey: @"one"]; the other key be marked as well.
Currently I do so like this:
- (void)setObject:(NSString *)anObject forKey:(NSString *)aKey
{
BOOL shouldNotify= [@"one" isEqual: aKey];
if(shouldNotify) [self willChangeValueForKey: @"two"];
[properties setObject: aValue forKey: aKey];
if(shouldNotify) [self didChangeValueForKey: @"two"];
}
Is this an appropriate course of action, or a hack? I could also just
have it be that whenever the dictionary is changed the other key be
marked as well, but that would be inefficient. Is there a way around
this?
Thanks in advance,
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.