I experience an odd behaviour regarding saving an NSPersistentDocument. I can create a new document which is autosaved without an issue. But when I save it write(to: ofTyp
-
Good news and bad news
I have succeeded to reproduce the exact same error with Xcode 9.2 running on MacOS 10.13.2.
- The version 1 of document file is still in a Autosave directory.
- Document.xcdatamodel is updated to version 2 (Document 2.xcdatamodel)
- When the application starts, the file of version 1 in the Autosave directory is read with
NSBinaryStoreSecureDecodingClasses
option.
- The app works well.
- File > Save... triggers
NSPersistentStoreCoordinator .migratePersistentStore()
aka -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:]:
- During the course of
migratePersistentStore
, NSBinaryStoreSecureDecodingClasses
option is not set for both writing to and reading from a temporary file.
- The error occurs.
Somewhat strange for me. Why the migration is executed upon saving, instead of upon opening a file? The lightweight migration has been already done at the step 3?
EDIT:
It seems that the name of migratePersistentStore
does not mean migration from old version to new version. It seems to mean migrate from an old persistent store with an old URL aka filename and/or file format to a new persistent store with a new URL and/or file format. So it is called when Save As... or Saving a new document which is already saved in an Autosave directory.
- 热议问题