Re: Instantiating window from nib
Re: Instantiating window from nib
- Subject: Re: Instantiating window from nib
- From: Vince DeMarco <email@hidden>
- Date: Tue, 16 Oct 2001 10:43:54 -0700
On Monday, October 15, 2001, at 10:44 pm, Jeff LaMarche wrote:
On Monday, October 15, 2001, at 10:51 AM, James DiPalma wrote:
Are there advantages to using NSWindowController? Its design seems to
provide many of its features for NSDocument (or any document) window:
all of the relevant features in the doc can easily be done in IB for a
non-document window. Using an NSWindowController simply to load a nib
file seems like an unnecessary introduction of a somewhat confusing
class.
Well, as the person who asked the original question, I'm certainly no
expert here, but NSWindowController does seem to provide some additional
functionality that is useful, although not particularly hard to implement
yourself. For one thing, it automatically cascades new windows, and
stores window size and location information in the user defaults,
restoring them the next time. These are obviously things primarily
intended for the document based application, but they can be useful in
other situations.
Using NSBundle to load a nib file seems to be easier for a
non-NSDocument based application. I would also recommend against
NSWindowControllers for things like inspectors, preferences and stuff
like that.
I wouldn't say easier, but probably more efficient - NSWindowController
gives you a lot of stuff you might not need if you're not creating a
multi-document application. It's hard to argue easier when
NSWindowController does things you would have to code for otherwise.
What NSWindowController is is make sure all of the top level objects that
come out of a nib file are properly released when the window is closed,
This is pain to do yourself cuz you need to make outlets to every toplevel
object in the nib file (see the IB release notes for more info)
vince