Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BadWolf13

macrumors 6502
Original poster
Dec 17, 2009
271
0
I've been wondering something for a while, and I can't seem to figure it out. When I work in Interface Builder, it allows me to have multiple windows within a single IB file, and yet all the example programs that come with Xcode and are available for download from Apple all show separate IB files for each window or panel within a program. Is there a problem with having multiple windows, is it a preference thing, is one method clearly better than the other?
 
Is there a problem with having multiple windows, is it a preference thing, is one method clearly better than the other?

No; Yes; and It depends.

No, there's no problem with multiple windows, if that's how your app is structured.

Yes, it's mostly preference (or the design sense) of the developer.

It depends on what the developer is trying to accomplish.

Ultimately, if you can't think of a good reason for multiple windows in a single nib, then don't worry about it. Just know it's there if you ever want it.
 
You've piqued my curiosity. Excluding helper windows, when would it make sense to have multiple windows in a single xib?

Suppose you have a relatively small app that can show a log or status record. Would you use a separate nib/xib for that? Or a small game that has a high-scores window. Putting everything into one nib means everything must be instantiated at launch time, so if the resources are relatively minimal and development is not spread out over a large group, sometimes it is simply easier to put it all into one nib.
 
Ok, for example's sake, I'm making a document based program that handles different types of documents, with different windows for each document type, it's likely best to make a different XIB file for each document type?

If on the other hand, I've got a pop-up window that's too complicated to be created programmatically, would it be a good idea to put it in the same XIB file as the parent window?
 
For your example of different document types (meaning, I assume, a "Cocoa Document-Based" app), yes, I would think you would absolutely want to separate those windows into separate XIBs. The controller has to associate a XIB with a document.

Other than that I would say it's up to you. If it makes sense for things to be together (like accessory panels and views, and so forth), then sure, you could keep them together. Just remember when you load a XIB you load the whole thing, so you might not wish to load things that may not even be used every time your app is run (let's say a preferences panel or export options panel).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.