You're trying to create the instance of NSWindowController
by instantiating it in another nib. However, when you instantiate an object in a nib file, it is initialized by calling -initWithCoder:
.
-initWithCoder:
is not a designated initializer of NSWindowController
, so your instance of NSWindowController
never actually loads its nib.
Instead of instantiating your NSWindowController
instance by placing it in the MainMenu.xib
file in Interface Builder, create it programmatically:
In AppDelegate.h:
@class YourWindowController;
@interface AppDelegate : NSObject
{
YourWindowController* winController;
}
@end
In AppDelegate.m:
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification*)notification
{
winController = [[YourWindowController alloc] init];
[winController showWindow:self];
}
- (void)dealloc
{
[winController release];
[super dealloc];
}
@end
In YourWindowController.m:
@implementation YourWindowController
- (id)init
{
self=[super initWithWindowNibName:@"YourWindowNibName"];
if(self)
{
//perform any initializations
}
return self;
}
@end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…