Suppose that two objects A and B are observing a key on a third
object C. Suppose further that from its observeValueForKeyPath
method, A releases B, causing B's dealloc method to be called, and
that B's dealloc method properly calls removeObserver. Then, despite
the call to removeObserver, it looks like Cocoa tries to call
observeValueForKeyPath on B anyway, which is a call off into empty
space.
This is on 10.4.11.
1) Am I doing something wrong?
2) Is this documented somewhere? (I didn't find it anywhere)
3) If this is already known, is there a customary pattern for
avoiding the problem? "Never release from observeValueForKeyPath" is
a bit harsh!
Test code at end. To use, make MainMenu.nib instantiate the object
'test', and make a window with a checkbox bound to values.testkey on
UserDefaultsController. Check the box. Here is the result if this is
done with NSZombieEnabled=YES: