views:

76

answers:

2

I have a nib file I want to open up, but it is just an info panel so I dont need any methods for it. Is there a way I can just open it. I am not in a class that is a subclass of NSWindowController.

A: 

Look at NSBundle Additions Reference.

Martin Cote
Darn I just realized I didn't make a new nib, I just made a new window in the same nib file. Nevermind.
Jake Schwartz
+1  A: 

Yes, you can make any object the owner of a xib. That object, however, has to "host" the outlets used in your xib.

For example, if you have a "ConfirmationSheet.xib", just declare your outlets in the class you want to "own" that instance of the xib, set the File's Owner class to your class, then connect your outlets. Let's use an outlet named "confirmHowMuchSlider" as an example: when the xib is loaded, your class's "confirmHowMuchSlider" outlet will be connected to the slider you connected in the xib and that's that.

Note this generally a sign of not-so-good design, IMO. If it's complicated enough to be in its own xib, it should have its own controller. If it's not complicated (just a sheet), you can sacrifice another 0.001 seconds of app or document load time and put it in a more central xib. :-)

Remember, if you are doing this for performance reasons, a separate round of disk access just to load a single sheet with a few buttons is generally worse in performance than loading more stuff in one go from one xib. All things are a tradeoff.

Joshua Nozzi