Skip navigation.
 
mlRe: Unregistering KVO observers-solved
FROM : Steve Nicholson
DATE : Mon Apr 21 20:07:29 2008

On Apr 18, 2008, at 2:35 PM, Hal Mueller wrote:

> Maybe try
> [[NSNotificationCenter defaultCenter] removeObserver:nil name:nil 
> object:self]
> in your dealloc method?  I think that will patch the symptom, but I 
> still don't understand why you're getting the original error.


I tried that, but no luck. Also, I'm doing this in windowWillClose: 
in my NSWindowController subclass, not dealloc.
>
> On Apr 17, 2008, at 10:05 PM, Steve Nicholson wrote:

>> When my app was simply an NSDocument, it worked fine: when the 
>> window closed, the bindings were automatically broken. But now 
>> that I'm using NSDocument and NSWindowController, they aren't.

>
> The section on Window Closing Behavior in the Document-Based 
> Application Overview might help:
>
> file:///Developer/Documentation/DocSets/
> com.apple.ADC_Reference_Library.CoreReference.docset/Contents/
> Resources/Documents/documentation/Cocoa/Conceptual/Documents/
> Concepts/WindowClosingBehav.html


I tried sending setShouldCloseDocument:YES to my 
mainWindowController, but no change.

> This bit looks important though.  Makes me wonder if you've got 
> things wired up in IB the way they should be, or some other similar 
> hard-to-notice glitch.


I put together two simple test cases for my bindings/KVO problem. One 
that was NSDocument-based and one NSDocument/NSWindowController-
based. In doing so, I finally figured out my problem. The NSDocument 
has an object called "problem" that has the data I'm looking at. When 
I set bindings in the NSWindowController, I had them still bound to 
the property "problem" and added "problem" and "setProblem" methods 
to my NSWindowController subclass. When I changed the bindings to 
"document.problem..." and removed the NSWindowController's "problem" 
and "setProblem" methods, the message "An instance 0x3434f0 of class 
ExperimentalData is being deallocated while key value observers are 
still registered with it." stopped appearing in the log when I closed 
the window.

-Steve

Related mailsAuthorDate
mlUnregistering KVO observers Steve Nicholson Apr 17, 21:59
mlRe: Unregistering KVO observers Hal Mueller Apr 18, 06:01
mlRe: Unregistering KVO observers Steve Nicholson Apr 18, 07:05
mlRe: Unregistering KVO observers Hal Mueller Apr 18, 23:35
mlRe: Unregistering KVO observers-solved Steve Nicholson Apr 21, 20:07