views:

278

answers:

2

I'm building a framework in Xcode, and I need to display a window when a function is called. How do I get my framework to display a window that I build in Interface Builder? Step by step instructions would be greatly appreciated!

Thanks, Chetan

A: 

Use an NSWindowController as the window's File's Owner, and then just call [myWindowController showWindow:nil].

Dave DeLong
I did that, but when I call the function that shows the window (the one that calls [myWindowController showWindow:nil]) from an application that uses the framework I am making, the window doesn't show. Could you please be more explicit in what I have to do to make it work? Thanks so much!
Chetan
+1  A: 

You'd call it like this:

    MyWindowController* controller = [[MyWindowController alloc] 
     initWithWindowNibName:@"Foo"];
    [controller showWindow:nil];

Where Foo is the name of the nib file, and MyWindowController is a subclass of NSWindowController that you set to be the owner of the nib file.

In this case, it's important to subclass NSWindowController because it will automatically search for the nib file the bundle that the class lives in.

Ken Aspeslagh
Perfect, it worked. In case it's needed, here's a bit more information on the solution: http://homepage.mac.com/carlile/iblog/C2041678833/E20090109223530/index.html
Chetan