Skip navigation.
 
mlProblems with object observing own key
FROM : Colin Cornaby
DATE : Sun May 11 22:36:03 2008

I have an object that observes a few of it's own keys. This works 
fine. The problem comes at dealloc time...

I get messages logged to the console for each of the it's own keys 
that the object is observing like:

] An instance 0x1c247f50 of class GSLayerView is being deallocated 
while key value observers are still registered with it. Observation 
info is being leaked, and may even become mistakenly attached to some 
other object. Set a breakpoint on NSKVODeallocateBreak to stop here in 
the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x1c2cd520> (
<NSKeyValueObservance 0x1c270340: Observer: 0x1c247f50, Key path: 
hasBackgroundColor, Options: <New: YES, Old: YES, Prior: NO> Context: 
0x3281c, Property: 0x15f4df50>
...

I do remove the observers in my dealloc method, but it seems these 
warnings are being fired before my dealloc method is even called.

Are there any ways to fix my code to deal with this behavior?

Related mailsAuthorDate
mlProblems with object observing own key Colin Cornaby May 11, 22:36
mlRe: Problems with object observing own key Hamish Allan May 11, 23:08
mlRe: Problems with object observing own key Colin Cornaby May 11, 23:19
mlRe: Problems with object observing own key Kyle Sluder May 11, 23:47
mlRe: Problems with object observing own key Colin Cornaby May 11, 23:53
mlRe: Problems with object observing own key Mike Abdullah May 12, 00:09
mlRe: Problems with object observing own key Adam R. Maxwell May 12, 00:13