检查 Cocoa Document Based 应用程序中保存是否成功
我有一个基于 Cocoa 文档的图片编辑应用程序。像往常一样,我的应用程序有 File ->保存菜单和文件 ->另存为菜单。
文件-> Save 菜单链接到 saveDocument:在 NSDocument 子类
File -> 中另存为菜单链接到 saveDocumentAs: 在 NSDocument 子类中
在这两种情况下,在成功保存时,我想向用户显示一个 NSAlert 表,说明保存已成功,并且此表还向用户提供将文档上传到的选项Facebook 等。
我如何知道文档已成功保存?
我知道如果是文件 ->另存为 我可以创建一个新的操作方法 mySaveDocument: 并
saveDocumentWithDelegate:didSaveSelector:contextInfo:
从 mySaveDocument: 调用,但是我应该为 File -> 做什么?另存为?
I have a Cocoa document based picture editing application. As usual, my application has both File -> Save menu and File -> Save As menu.
File -> Save menu is linked to saveDocument: in NSDocument subclass
File -> Save As menu is linked to saveDocumentAs: in NSDocument subclass
In both cases, on a successful save, I want to present a NSAlert sheet to user saying that the save was successful and this sheet also presents the user with an option to upload the document to Facebook etc.
How do I know, that the document got saved succesfully?
I understand that in case of File -> Save As I can create a new action method mySaveDocument: and invoke
saveDocumentWithDelegate:didSaveSelector:contextInfo:
from mySaveDocument: but what should I do for File -> Save As ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的
NSDocument
子类中,重写:每当保存文档时都会调用此方法。
有关保存文档时发生的情况的更多信息,请阅读 基于文档的应用程序概述文档的文档架构页面中的消息流。
In your
NSDocument
subclass, override:This method is called whenever a document is saved.
For more information on what happens when a document is saved, read the Message Flow in the Document Architecture page of the Document-Based Applications Overview document.