Cocoa NSDocument:让自动保存工作
文档简单地指出将 setAuto savingDelay
设置为任何内容 > 共享文档控制器上的 0 应该可以做到这一点,但是在调用
[[NSDocumentController sharedDocumentController] setAutosavingDelay:2.0];
我的控制器后,自动保存似乎不起作用:我在 ~/Library/Autosave Information/
中既没有看到任何内容,也没有
[[[NSDocumentController sharedDocumentController] currentDocument] autosavedContentsFileURL]
初始化。
请注意,在我的应用程序中,正常加载和保存工作正常(keyedarchivers、我的文档的基于 nscoding 的类等)。
Documentation simply states that setting setAutosavingDelay
to anything > 0 on the shared doc controller should do it, but after calling
[[NSDocumentController sharedDocumentController] setAutosavingDelay:2.0];
in my controller, autosave doesn't seem to work: I neither see anything in ~/Library/Autosave Information/
, nor is
[[[NSDocumentController sharedDocumentController] currentDocument] autosavedContentsFileURL]
initialized.
Note that in my app, normal loading and saving work fine (keyedarchivers, nscoding-based class for my docs, etc).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否完全覆盖了 -updateChangeCount: ? 我非常确定苹果的实现是启动自动保存计时器的代码。 另外,如果你尝试使用更长的计时器会怎么样?
Have you overridden -updateChangeCount: at all? I'm pretty certain that Apple's implementation is the code that starts up the autosave timer. Also, what if you experiment with a longer timer?
有些人发现目录
〜/库/自动保存信息
属于 root 所有,因此不能在其中写入文件。 参见示例
http://discussions.apple.com/thread.jspa?threadID=2252306
我不知道这个 bug 是如何产生的,但我被它咬住了——该目录是在 2010-06-17 12:19 创建的,我认为从那一刻起权限就是错误的。
Some people find that the directory
~/Library/Autosave Information
is owned by root, and so files can not be written therein. See for example
http://discussions.apple.com/thread.jspa?threadID=2252306
I don't know how the bug arises but I was bitten by it -- the directory was created 2010-06-17 12:19 and I assume that the permissions were wrong from that moment.