Display Window with Cocoa Framework in Xcode

I am creating a framework in Xcode and I need to display a window when a function is called. How do I get my infrastructure to display the window that I create in Interface Builder? Step by step instructions would be greatly appreciated!

Thanks Chetan

+6
objective-c frameworks xcode cocoa
source share
3 answers

You would call it this way:

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

Where Foo is the nib file name, and MyWindowController is the NSWindowController subclass that you specified as the owner of the nib file.

In this case, it is important to subclass NSWindowController, because it will automatically search for the nib file in the package in which the class lives.

+7
source share

Use NSWindowController as the owner of the window file, and then simply call [myWindowController showWindow:nil] .

+1
source share

This is probably due to the fact that it does not support links to the created NSWindowController. If you do not save it, the object will be deleted.

0
source share

All Articles