• 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
Re: Why NSWindowController for non-document windows?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why NSWindowController for non-document windows?


  • Subject: Re: Why NSWindowController for non-document windows?
  • From: glenn andreas <email@hidden>
  • Date: Tue, 13 Sep 2005 08:35:59 -0500


On Sep 13, 2005, at 8:20 AM, Stefan Haller wrote:

Of course, I *am* using nib files other than the main nib already. But
I can either do this by deriving my window controller from NSObject,
using


  [NSBundle loadNibNamed:@"NibName" owner:self];
  [mWindow makeKeyAndOrderFront:self];

(where mWindow is an outlet of my controller which is connected in
Interface Builder), or by deriving from NSWindowController, using

  [self initWithWindowNibName:@"NibName"];
  [self showWindow:self];

I wonder why the second method is considered preferable to the first.


From the NSWindowController documentation:

The relationship between an NSWindowController (or, simply, a window controller) and a nib file is important. Although a window controller can manage a programmatically created window, it usually manages a window in a nib file. The nib file can contain other top- level objects, including other windows, but the window controller’s responsibility is this primary window. The window controller is usually the owner of the nib file, even when it is part of a document-based application. Regardless of who is the file’s owner, the window controller is responsible for freeing all top-level objects in the nib file it loads.
That last sentence is the most important one for answering your question - all top level objects of a nib file need to be freed when closing the window. NSWindowController keeps track of all of that for you - otherwise you've got to do it manually.

Now, if those other windows are never closed, it's not as big of a deal...


Glenn Andreas email@hidden <http://www.gandreas.com/> wicked fun! quadrium | build, mutate, evolve | images, textures, backgrounds, art

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Why NSWindowController for non-document windows? (From: email@hidden (Stefan Haller))

  • Prev by Date: Re: Why NSWindowController for non-document windows?
  • Next by Date: Re: [ANN] HOM paper available
  • Previous by thread: Re: Why NSWindowController for non-document windows?
  • Next by thread: Web VIew?
  • Index(es):
    • Date
    • Thread