Re: WindowController


Jack Brindle
 

Is there a corresponding line of code that sets self.prefController to nil when the window is closed?
As I understand it, the property will only be set to nil if it is declared as weak, which is most likely
not what you want.

I get the feeling I’m missing something here, though. This is not something you would normally miss…

- Jack

On Jul 17, 2017, at 7:12 AM, Gerriet M. Denkmann <g@...> wrote:

This works:

- (void)showPreferences: (NSMenuItem *)sender;
{
(void)sender;

// if ( self.prefController == nil ) // this line should not be commented out
{
self.prefController = [ [ NSWindowController alloc ] initWithWindowNibName: @"PrefWindow" ];
};

[ self.prefController showWindow: self ];
}

But when I *not* comment out the if… line it works exactly once.

How can I convince my NSWindowController to keep its window?

Gerriet.



Join {cocoa@apple-dev.groups.io to automatically receive all group messages.