I am trying to learn how to open a second window in an Application (Mac OS X, 
not iOS). I have created a separate Nib file for loading the second window. I 
have a couple of questions


Q1. The "Resource Programming Guide" says the following

"The NSWindowController class also provides automatic support for loading nib 
files. If you create custom window controllers programmatically, you have the 
option of initializing them with an NSWindow object or with the name of a nib 
file. If you choose the latter option, the NSWindowController class 
automatically loads the specified nib file the first time a client tries to 
access the window. After that, the window controller keeps the window around in 
memory; it does not reload it from the nib file, even if the window’s “Release 
when closed” attribute is set in Interface Builder."

I have created a Nib file (MySecondWindow.xib), I also created a 
NSWindowController class (MyWinController). In IB the "File's Owner" of the new 
Nib file is set to MyWinController.


I guess I can show the second window by doing something like this in some 
method in MyDocument.m -

mySecondWin = [[MyWinController alloc] initWithWindowNibName:@"MySecondWindow"];

How do I release the memory once the window is closed? The description above 
says that the window is kept in memory even if closed.

Q2. In the same "Resource Programming Guide" a later section talks about 
loading Nib files programmatically using NSBundle and NSNib classes to load a 
new Nib. Using NSNib allows you to keep the NSNib object around to load 
additional "copies" of the same type of window (with other controllers).

Releasing the NSNib object and any mySecondWin controller objects will release 
all memory associated with MySecondWindow. Correct?

Thanks
Hrishi

_______________________________________________

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