确定在基于 NSDocument 的应用程序中的“保存面板”中按下了哪个按钮
当在基于 NSDocument 的应用程序中关闭保存对话框时,我应该如何确定按下哪个按钮(保存、取消)?当从菜单中选择保存时,保存面板是 NSDocument 提供的默认设置。
我希望有机会在调用 - (BOOL)writeToURL:ofType:error: 之前更改一些变量。
谢谢...
How should I determine which button is pressed (save, Cancel) when the save dialog is dismissed in an NSDocument based application ? The save panel is the default provided by NSDocument when save is selected from menu.
I would like to have the chance to change some vars before - (BOOL)writeToURL:ofType:error: is invoked.
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将一个对象设置为保存面板的委托并实现
‑panel:validateURL:error:
方法。在按下“保存”按钮之后但在保存文档之前调用该方法。但是,我质疑这样做的必要性。仅在保存文件时才需要更改哪些类型的变量?你想实现什么目标?
You could set an object as the save panel's delegate and implement the
‑panel:validateURL:error:
method. That method is called after the Save button is pressed but before the document is saved.However, I'd question the need to do this. What sort of variables do you need to change only when the file is saved? What are you trying to accomplish?