我真的没有做太多事情,而且我已经陷入困境。
到目前为止我已经完成了:
添加 NSWindowController 子类( MikesWindowController.h & .m)
从 MikesDocument.m 中删除 windowNibName (因为我正在实施自己的 WindowController子类。)
我试过了:
如果NSLog将返回 init , windowControllerDidLoadNib , applicationDidFinishLaunching ,则进行测试。只有init的NSLog打印出来。
并测试主菜单 - > 文件 - >编译我的文档应用程序后新。
我是否正确实施此权利?谢谢。任何建议都会很棒!在 MikesDocument.m
下-(void)makeWindowControllers{
MikesController *controller = [[MikesWindowController alloc]init];
[self addWindowController:controller];
}
答案 0 :(得分:0)
经过深思熟虑,我找到了答案。哇噢。享受未来。
下面我在NSWindowController子类中实现了 initWithWindowNibName ,看看它是什么样的:
<强> MikesWindowController.m 强>
-(id) initWithWindowNibName:(NSString *)windowNibName{
self = [super initWithWindowNibName:windowNibName];
return self;
}
(下)再回到主文档,我更正了 makeWindowController 方法,并使用&#34; MikesDocument&#34; (对于MikesDocument.xib)实例化我的控制器并添加它。
<强> MikesDocument.m 强>
-(void)makeWindowControllers{
MikesWindowController *controller =
// must tell controller which nib file to use.
[[MikesWindowController alloc]initWithWindowNibName:@"MikesDocument"];
[self addWindowController:controller];
}
成功!不要打扰调用init或实现init,因为它随时会返回错误。