Loading a Nib file
Loading a Nib file
- Subject: Loading a Nib file
- From: Hrishikesh Murukkathampoondi <email@hidden>
- Date: Sat, 16 Oct 2010 21:11:11 +0530
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@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