I created a new Swift application from the Core Data document based template. The application is working fine, but for a new version I would like to add lightweight migration.
In the core data documentation I read, that I just have to add some options to in the addPersistentStoreWithType:configuration:URL:options:error:
method, but where is actually no hint where this method is called/added.
I have the Document
class which is derived from NSPersistentDocument
and also the application delegate.
addPersistentStoreWithType:configuration:URL:options:error:
called?It's (hidden) in the documentation of NSPersistentDocument
.
You can customize the architecture of the persistence stack by overriding the
managedObjectModel
property andconfigurePersistentStoreCoordinator(for:ofType:modelConfiguration:storeOptions:)
method. You might wish to do this, for example, to specify a particular managed object model.
Override func configurePersistentStoreCoordinator(for url: URL, ofType fileType: String, modelConfiguration configuration: String?, storeOptions: [String : AnyObject]? = [:])
. Add your options to storeOptions
and call super.