因为我使用的是自定义核心数据堆栈,所以我会覆盖init, readFromURL, writeToURL
和revertToContentsOfURL
函数。
当我点击"浏览所有版本"时,我的文件的先前版本是openend并调用init。但是我收到以下错误:
尝试在路径中添加只读文件...将其添加为只读 这将是一个很难的错误;
您必须指定NSReadOnlyPersistentStoreOption。
我现在的问题是:如何知道正在打开的文件是普通文件还是版本化文件?
答案 0 :(得分:0)
Ok, found it. In a subclass of NS(Persistent)Document, when determining the options for your NSPersistentStore.
if self.inViewingMode {
[NSSQLitePragmasOption: yourPragmaOptions,
NSReadOnlyPersistentStoreOption: "YES"] }