Petr Smejkal
Petr Smejkal

Reputation: 101

Splitting Core Data Model Configurations in production app

I have a production app using Default configuration which is used with CloudKit. I now want to introduce new entities which will not be synced with iCloud. I understand that two new configurations will need to be created (one local and one iCloud) and entities moved under the newly created configs. I will be using the following setup:

init { 
    persistentContainer = NSPersistentCloudKitContainer(name: "MockDataModel")

let defaultDirectory = NSPersistentCloudKitContainer.defaultDirectoryURL()

let localStore = NSPersistentStoreDescription(url: defaultDirectory.appending(path: "local.sqlite")) localStore.configuration = "Local" 

let cloudStore = NSPersistentStoreDescription(url: defaultDirectory.appending(path: "cloud.sqlite")) cloudStore.configuration = "Cloud" cloudStore.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.com.mockContent")

persistentContainer.persistentStoreDescriptions = [ localStore, cloudStore ]

persistentContainer.loadPersistentStores { _, _ in }

}

Are there any implications in creating new configurations for production app where users have data stored in iCloud? Will the migration be handled automatically?

Upvotes: 0

Views: 26

Answers (0)

Related Questions