I have an object that implements the indexed accessor methods for a key called contents
. In those accessors, I call willChange:valuesAtIndexes:forKey:
and didChange:valuesAtIndexes:forKey:
when I modify the underlying array.
I also have a custom view object that is bound to contents
via an NSArrayController
. In observeValueForKeyPath:ofObject:change:context:
the only value in the change dictionary for the NSKeyValueChangeKindKey
I ever see is NSKeyValueChangeSetting
. When I'm adding objects to the array, I expect to see NSKeyValueChangeInsertion
.
Recreating my view's internal representation of the objects it observes every time I insert a single item -- particularly when I'm bulk loading hundreds of items -- presents quite a performance problem, as you'd imagine. What am I doing wrong that Cocoa seems to think I'm setting a completely new array each time I add or remove a single item?