Reputation: 52458
My OS X app has two windows. I've put one in MainMenu.xib, and the other in SecondaryWindow.xib.
When I run my app, the window in MainMenu.xib shows. I also want the second window in SecondaryWindow.xib to show at startup. How do I achieve this? Was it a good idea to use a separate xib file for the second window?
Upvotes: 3
Views: 1115
Reputation: 24439
If you'd like to do it without a line of code, add NSWindowController
object to MainMenu.xib
and write second xib's name to it's property. When MainMenu.xib is loaded, this window controller will be created and will load the second xib, causing the second window to pop up if it's configured to be visible on startup.
Or do it programmatically from e.g. applicationDidFinishLaunching:
or awakeFromNib:
.
Besides being an instrument for breaking UI into independent modules, separate xibs make it possible, for example, to unload some of them and save memory (e.g. when window is closed), or load one multiple times.
In your case, if both windows always have to be in memory, you can safely keep them in the same xib.
Upvotes: 3