So I\'m trying to open a new NSWindow like so:
NSWindowController *winCon = [[NSWindowController alloc] initWithWindowNibName:@\"NewWindow\"];
[winCon showWi
First, the name of the initializer isn't -initWithNibName:
, but -initWithWindowNibName:
.
Second, and this is true if you're using ARC, your window goes foom because you don't have a strong reference for your instance of NSWindowController
. When the method ends, so does your reference.
If, say, you were to do this instead in your application delegate interface:
@property(strong) NSWindowController *winCon;
And synthesized it in your implementation file:
@synthesize winCon;
Then you could set up like this:
self.winCon = [[NSWindowController alloc] initWithWindowNibName:@"NewWindow"];
[self.winCon showWindow:self];
Now your window won't disappear. The window controller will be released when the application closes.