One Quickie

Using an NSWIndowController to load a window (NSWindow->General)
Here's how I like doing things. First make a subclass of NSWindowController:
@interface BWInspector : NSWindowController
    // ivars, IBOutlets, etc

// IBActions, etc

+ (BWInspector *) sharedInspector;
@end // BWInspector
Then make a nib file with the window, the controls, and other fun stuff you want. This one lives in English.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);

} // sharedInspector
That will load the nib file, set up the connections and then open the window for display

borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book