Post

Replies

Boosts

Views

Activity

Reply to Old Core Data Sync in to CloudKit "iCloud"
The pre-existing data does not sync. Only the newly-added data syncs. What I am doing is creating a struct for every core data entity, stuffing those structs with the core data and then going from structs to core data. My app is old and its store file is in the Document directory whereas the new store files are located in the Library directory. Do you think that your app is that old?
Aug ’20
Reply to Questions About Updating Older Core Data / iCloud App to Core Data / CloudKit
Actually, I've come up with another scheme. I have created Decodable structs for each core data entity. The new core data's store file location is in the Library folder whereas the old core data's store file is located in the Documents directory. I plan on saving every entity in structs and then go from structs to core data using two managed object contexts, one to grab the data and the other to save. This will allow that data to sync.
Aug ’20
Reply to Core Data + CloudKit > how to incorporate existing app data into new NSPersistentCloudKitContainer
My app is so old, the sqlite file is stored in the Documents directory and not the Library/"Application Support" directory as the new files are. I've created a struct for every entity in my core data and made the structs Codable. NSManagedObjects are not Codable. There were some issues as NSNumbers are not Codable, but I replaced those with Ints in the structures. I have written methods which stuff the structs from core data and have written methods which stuff the core data entities from the structs. I've also written methods to encode and decode the struct data using the JSON encoder/decoder. The plan is to grab the data from the old directory, put all of the core data objects into structs and then put the struct data into the new store file. That will sync the data. This will require a separate ManagedObjectContext for the old data. I also plan on saving the encoded data out for the user in iCloud Drive as backup files and will allow the user to restore their data from a backup file. Whew!
Aug ’20
Reply to Core Data + CloudKit > how to incorporate existing app data into new NSPersistentCloudKitContainer
Try adding a UUID attribute to all of your entities in the model. You'll have to migrate, but that should be easy as it's only adding one attribute per entity. Then fetch every entity and add the UUID to every managed object. Then save. I have done this with a sample project and it seemed to work. You might want to try this on an experimental project first. Another way would be to have two managed object contexts and copy each one and save in the context with the CloudKit store. Although relationships are an issue.
Jul ’20