When you insert or remove objects in a KVO compliant manner, your observer is informed of the specifics of the change via the change dictionary:- (void) observeValueForKeyPath: (NSString *) keyPath ofObject: (id) object change: (NSDictionary *) change context: (void *) contextThe
NSKeyValueChangeKindKeykey in the dictionary tells you if the change was an insertion (
NSKeyValueMinusSetMutation) or a deletion (
If it is an insertion, the
NSKeyValueChangeIndexesKeyis an index set that contains the index of the inserted object. You can query the collection for the object at that index to get the new object.
if it a deletion, the
NSKeyValueChangeIndexesKeytells you the index where the object was deleted from, and the
NSKeyValueChangeOldKeycontains an NSArray of objects which were removed, in case you want to hang on to it, or use it to clean out some of your data structures.