views:

73

answers:

1

The method

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
}

has a parameter change which is a dictionary that contains information about the nature of the value change, how would I find out what was in this dictionary?

+3  A: 

Here's a list of the keys used by the change dictionary.

An extract:

Keys used by the change dictionary

These constants are used as keys in the change dictionary passed to observeValueForKeyPath:ofObject:change:context:.

NSString *const NSKeyValueChangeKindKey;
NSString *const NSKeyValueChangeNewKey;
NSString *const NSKeyValueChangeOldKey;
NSString *const NSKeyValueChangeIndexesKey;
NSString *const NSKeyValueChangeNotificationIsPriorKey;
Abizern
Also, remember to specify the NSKeyValueObservingOptionNew and/or NSKeyValueObservingOptionOld bitwise flags when setting up the observation.
iKenndac
How come each of them seem to mean more than one thing? And why do they make the descriptions so complicated?
Joshua
Firstly, they look different to me. e.g `ChangeOld` is not the same as `ChangeNew` is not the same as `ChangeIndexes`. Secondly, they're complicated because they are specific. All the links to secondary documentation may look messy, but they reduce repetition.
Abizern