Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Window with Cocoa Framework in Xcode

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

like image 644
Chetan Avatar asked Dec 24 '09 04:12

Chetan


2 Answers

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 within the bundle that the class lives in.

like image 110
Ken Aspeslagh Avatar answered Oct 17 '22 09:10

Ken Aspeslagh


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

like image 1
Dave DeLong Avatar answered Oct 17 '22 11:10

Dave DeLong