使用通知关闭特定 NSDocument 实例
我有以下问题。我正在尝试在我构建的小型 IDE 中重现类似 XCode 的“新项目”工作流程。为此,当用户选择“新项目”时,我有一个工作表在由文档窗口控制器创建的窗口中运行模式。该工作表从笔尖启动,并以逐步的方式加载多个子视图(通过视图控制器),以设置项目(类型 -> 参数...等)以保存新项目。到目前为止,一切都很好。
我遇到的问题是当我尝试在保存之前取消该过程时。我无法弄清楚如何在不关闭可能打开的其他文档实例(也称为“项目”)的情况下关闭模式表和文档实例。
我的应用程序有一个委托,一个通过 NSWindowController 和其他几个控制器和笔尖控制的 NSDocument 类。目前,我正在考虑在应用程序委托中实现基于通知的方法,但我无法掌握。
如果您能为我指明正确的方向,我将不胜感激。
最诚挚的问候,
汤姆
I have the following issue. I am trying to reproduce an XCode-like "new project" workflow in a small IDE I build. For this I have a sheet that runs modal in the window created by the doc window controller when user selects "New project". The sheet is inited from a nib and loads several subviews (via view controllers) in a stepwise approach, to set up the project (type -> parameters ... etc) to the point of saving the new project. So far so good.
The problem I have is when I try to cancel the process BEFORE saving. I cannot figure how to close the modal sheet and the doc instance WITHOUT closing other doc instances (aka "projects") that might be opened.
My app has a delegate, a NSDocument class that is controlled via a NSWindowController and several other controllers and nibs. For now, I am thinking of implementing a notification-based approach in the application delegate, but I cannot get to a grip.
I would appreciate if you could point me in the right direction.
Warmest regards,
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还可以在按下取消按钮时调用操作方法。这样,操作方法就可以关闭工作表并关闭您的 NSDocument 子类实例。
You could also call an action method when the cancel button is pressed. This way the action method manages to close the sheet and close your NSDocument subclass instance.