Question

Loading NIB file using NSWindowController work but when window did loaded it showing and immediately hide. What happen? I don't know. Here is my code:

- (IBAction)loadMyWindow:(id)sender
{
    NSWindowController * windowController;

    if (windowController == nil) {
        windowController = [[NSWindowController alloc] initWithWindowNibName:@"myWindow"];
       [windowController window];
    }
}

Anybody have an idea?

Was it helpful?

Solution

In project with ARC we must announce a variable windowController outside the method loadMyWindow

NSWindowController *windowController; //for example here

- (IBAction)loadMyWindow:(id)sender
{
    if (windowController == nil) {
        windowController = [[NSWindowController alloc] initWithWindowNibName:@"myWindow"];
       [windowController window];
    }
}

OTHER TIPS

Just add the line [windowController showWindow:self]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top