• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDocument's -close method calls itself?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument's -close method calls itself?


  • Subject: NSDocument's -close method calls itself?
  • From: "Sean McBride" <email@hidden>
  • Date: Thu, 2 Jul 2009 13:34:36 -0400
  • Organization: Rogue Research Inc.

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@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSDocument's -close method calls itself?
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: NSTableView bug?
  • Next by Date: Re: User interface validation doesn't work, right?
  • Previous by thread: Re: UIImageView source
  • Next by thread: Re: NSDocument's -close method calls itself?
  • Index(es):
    • Date
    • Thread