GDB says that a KVO observer is registered even though it is not (or is it?).

Posted by Paperflyer on Stack Overflow See other posts from Stack Overflow or by Paperflyer
Published on 2010-04-29T18:25:01Z Indexed on 2010/04/29 18:27 UTC
Read the original article Hit count: 380

Filed under:
|
|
|

When my application is closed, the main controller class removes itself as Observer from the model and then releases the model. Like this:

- (void)dealloc {
    [theModel removeObserver:self
                  forKeyPath:@"myValue"];
    [theModel release];
    [super dealloc];
}

And right after that, the debugger says:

2010-04-29 14:07:40.294 MyProgram[13678:a0f] An instance 0x116f2e880 of class TheModel was deallocated while key value observers were still registered with it. Observation info was 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 0x100288450> (
<NSKeyValueObservance 0x1002aca90: Observer: 0x116f40ec0, Key path: myValue, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x116f80430>
)

where 0x116f2e880 is indeed the model and 0x116f40ec0 is indeed the controller.

How can the controller still be an observer when it just removed itself as an observer?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa