Here's how I like doing things. First make a subclass ofNSWindowController
:@interface BWInspector : NSWindowController { // ivars, IBOutlets, etc } // IBActions, etc + (BWInspector *) sharedInspector; @end // BWInspectorThen make a nib file with the window, the controls, and other fun stuff you want. This one lives inEnglish.lproj/BWInspector.nib
Then in that class method load the window:
+ (BWInspector *) sharedInspector { static BWInspector *g_inspector; if (g_inspector == nil) { g_inspector = [[BWInspector alloc] initWithWindowNibName: @"BWInspector"]; assert (g_inspector != nil); // or other error handling [g_inspector showWindow: self]; } return (g_inspector); } // sharedInspectorThat will load the nib file, set up the connections and then open the window for display