删除可可基于文档的应用程序中的保存功能
我目前正在开发 Apple 的 Mac 开发网站< 的 Web 浏览器项目< /a>.
我已经完成了该项目,但遇到了一些问题。我已将项目创建为基于文档的 Cocoa 应用程序,现在每当我在网络上的任何文本字段中输入文本时,红色交通灯按钮都会在中间显示一个黑点,表示未保存的文档。当我尝试关闭窗口或完全退出应用程序时,会弹出一个警告,就像 TextEdit 或 Pages 中的警告一样,提醒我未保存的更改。这不是什么大问题,但我希望有人能告诉我如何删除基于 Cocoa 文档的应用程序的该功能。
I am currently working on a web browser project from Apple's Mac Dev site.
I have completed the project, but have a bit of a problem. I have created the project as a Document-Based Cocoa Application, and now whenever I enter text in any text field on the web, the red traffic light button shows a black dot in the middle that signifies an unsaved document. When I try to close the window or entirely quit the application, a warning pops up like that in TextEdit or Pages where it alerts me to unsaved changes. It's not too much of a problem, but I would like if someone could please tell me how to remove that feature of a Cocoa Document-Based Application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的应用程序不是基于文档的,为什么要使用基于文档的应用程序?基于文档的应用程序本质上包括
打开
和保存
的概念;这是它们的基本组成部分。无论如何,您可以通过适当配置
NSDocument
来“解决”这个问题;覆盖正确的方法,否则会破坏更改计数和更改。文档的脏状态。但这只是一个解决方法。NSDocument
的文档包含您需要的所有信息。一个更简洁的整体解决方案是重构您的应用程序以不使用
NSDocument
。在 Cocoa 中创建多个窗口非常简单(与菜单项绑定的操作方法,其中操作方法加载 nib 文件;如果我没记错的话,您甚至仍然可以使用 NSWindowController)。Why a document based application if your application isn't document based? Document based applications inherently include the concept of
open
andsave
; it is a fundamental part of what they are.In any case, you could "work around" this by configuring
NSDocument
appropriately; override the proper methods and otherwise muck with the change count & dirty state of the document. But it'll be just that, a workaround. The documentation forNSDocument
has all the information you need.A cleaner overall solution would be to refactor your app to not use
NSDocument
. Creating multiple windows is quite straightforward in Cocoa (an action method tied to a menu item where the action method loads a nib file; if I remember correctly, you could even useNSWindowController
still).一个更简单的解决方案就是重写 isDocumentEdited 方法以始终返回 NO。
An easier solution would simply be to override the
isDocumentEdited
method to always return NO.