I have an NSWindowController subclass called _PreferencesWindowController
with the following implementation -
@synthesize window;
- (id)init {
self = [super initWithWindowNibName:@"PreferencesWindow"];
if (!self) return nil;
return self;
}
And I tried to show the window in _PreferencesWindowController
by using the following code -
_preferencesWindowController = [[_PreferencesWindowController alloc] init];
[_preferencesWindowController showWindow:nil];
It does nothing, and I checked _preferencesWindowController.window
is nil
from the debugger.
However if I call loadView
on _preferencesWindowController
the window can be loaded and is visible; _preferencesWindowController.window
is no longer nil-valued -
[_preferencesWindowController loadWindow];
I looked at Apple's documentation on NSWindowController it specifically says "you should never directly invoke loadWindow
", instead showWindow:
should be used. I'm wondering what I might have missed that resulted in the above-mentioned behaviour I have been seeing.