Hi all,

I'm trying to find somewhere to undo what was done in my NSDocument
subclass' initializer.  Specifically, to start/stop KVO observation.  It
seemed like 'close' would be a good place.

First, should/must one call super in one's 'close' implementation?  It
seems so.

After trying this, I've found a problem.  My document has several window
controllers and I've discovered that if I have several windows open then
close the main document window, that I end up in my 'close' method twice:

#0 -[MyProjectDocument close] // <---
#1 -[NSWindowController _windowDidClose] ()
#2 -[NSDocument close] ()
#3 -[MyProjectDocument close] // <---
#4 -[NSWindowController _windowDidClose] ()
#5 -[NSDocument _closeAlertSheet:wasPresentedWithResult:inContext:] ()
#6 -[NSAlert didEndSheet:returnCode:contextInfo:] ()
#7 -[NSApplication endSheet:returnCode:] ()

- (void)close
{
        [controller removeObserver:....];
        
        [super close];
}

Frame 3 is as I expect. I call removeObserver, then call super (frame
2).  Then AppKit brings me back to my close method (frame 0) and I
proceed to call removeObserver again, which throws an exception.

So where can I tear down what was done in init?  (Note: I can't use
dealloc because this is a GC app.)

Thanks,

--
____________________________________________________________
Sean McBride, B. Eng                 [email protected]
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to