Created
September 21, 2008 21:12
-
-
Save boucher/11908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) notifyForKey: (NSString *)aKey ofInstance: (id)instance prior: (BOOL)f | |
{ | |
unsigned count; | |
id oldValue; | |
id newValue; | |
if (f == YES) | |
{ | |
if ((allOptions & NSKeyValueObservingOptionPrior) == 0) | |
{ | |
return; // Nothing to do. | |
} | |
[change setObject: [NSNumber numberWithBool: YES] | |
forKey: NSKeyValueChangeNotificationIsPriorKey]; | |
} | |
else | |
{ | |
[change removeObjectForKey: NSKeyValueChangeNotificationIsPriorKey]; | |
} | |
oldValue = [[change objectForKey: NSKeyValueChangeOldKey] retain]; | |
if (oldValue == nil) | |
{ | |
oldValue = null; | |
} | |
newValue = [[change objectForKey: NSKeyValueChangeNewKey] retain]; | |
if (newValue == nil) | |
{ | |
newValue = null; | |
} | |
count = [observations count]; | |
while (count-- > 0) | |
{ | |
GSKVOObservation *o = [observations objectAtIndex: count]; | |
if (f == YES) | |
{ | |
if ((o->options & NSKeyValueObservingOptionPrior) == 0) | |
{ | |
continue; | |
} | |
} | |
else | |
{ | |
if (o->options & NSKeyValueObservingOptionNew) | |
{ | |
[change setObject: newValue | |
forKey: NSKeyValueChangeNewKey]; | |
} | |
} | |
if (o->options & NSKeyValueObservingOptionOld) | |
{ | |
[change setObject: oldValue | |
forKey: NSKeyValueChangeOldKey]; | |
} | |
[o->observer observeValueForKeyPath: aKey | |
ofObject: instance | |
change: change | |
context: o->context]; | |
} | |
[change setObject: oldValue forKey: NSKeyValueChangeOldKey]; | |
[oldValue release]; | |
[change setObject: newValue forKey: NSKeyValueChangeNewKey]; | |
[newValue release]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment