NSPersistentDocument: browse versions : Attempt to add read-only file

163 Views Asked by At

Because I am using a custom core data stack, I am overwriting the init, readFromURL, writeToURL, and revertToContentsOfURL functions.

When I click "Browse all versions", previous versions of my file are openend and init is called. However I get the following error:

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.

My question is now: how do I know if the file being opened is a regular file or a versioned file?

1

There are 1 best solutions below

0
user965972 On

Ok, found it. In a subclass of NS(Persistent)Document, when determining the options for your NSPersistentStore.

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