Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的基于文档的应用程序会在 cmd+w 时立即终止文档,并且不会保存。我该如何对此做出反应并提示保存文档或自动保存它?
使用该NSDocument方法updateChangeCount(_:)将您的文档标记为已编辑,其余的由 Cocoa 处理!
NSDocument
updateChangeCount(_:)
此外,如果您使用NSUndoManager所有更改,它会为您更新更改计数!
NSUndoManager
大多数时候,您应该在现有的 Cocoa 功能中寻找这些类型的“挂钩”,以便您的应用程序的行为方式与其他 OS X 应用程序完全相同,并在新的 OS 版本发布时继承新功能。