我在我的myDocument.m文件中实现了一些代码,它只是在启动时尝试加载上次使用的文档。但是,从全新安装启动后(或在删除之后运行上次使用的文件),不会显示“新”文档窗口。有谁知道要添加到我的代码来做到这一点?那就是:打开'新'文档?
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
NSURL *lastURL=[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:lastURL display:YES error:nil];
if (lastURL!=nil)
{
[docController openDocumentWithContentsOfURL:lastURL display:YES error:nil];
return NO;
}
return YES;
}
@Justin - 它的工作原理是打开最后使用的文档,但是当我清除列表并打开应用程序时,我想要一个新的文档出现 – Zakman411 2011-02-09 02:34:30
我明白了,只是试了一下。之前引发了一个例外,但我修复了它。 – 2011-02-09 02:38:43