gpt4 book ai didi

swift - NSPersistentDocument:浏览版本:尝试添加只读文件

转载 作者:行者123 更新时间:2023-11-30 13:39:18 26 4
gpt4 key购买 nike

因为我使用的是自定义核心数据堆栈,所以我将覆盖 init、readFromURL、writeToURLrevertToContentsOfURL 函数。

当我单击“浏览所有版本”时,文件的先前版本将打开并调用 init。但是我收到以下错误:

Attempt to add read-only file at path ... Adding it read-only instead.
This will be a hard error in the future;
you must specify the NSReadOnlyPersistentStoreOption.

我现在的问题是:我如何知道正在打开的文件是常规文件还是版本化文件?

最佳答案

好的,找到了。在 NS(Persistent)Document 的子类中,确定 NSPersistentStore 的选项时。

if self.inViewingMode {
[NSSQLitePragmasOption: yourPragmaOptions,
NSReadOnlyPersistentStoreOption: "YES"] }

关于swift - NSPersistentDocument:浏览版本:尝试添加只读文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35752158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com