NSPersistentCloudKitContainer: How to re-fetch a record from CloudKit?

Is there a way to ask NSPersistentCloudKitContainer to update a local managed object’s values by refetching them from CloudKit? Here is my scenario:

Let’s say I have a simple Address Book app that stores first name, last name, and phone number. I use NSPersisentCloudKitContainer to sync the data across a user’s devices.

Let’s say a user installs the app on their iPhone and iPad. They add a bunch of records. All is working well.

Now, I create version 2 of the app that adds a Notes field. The user installs version 2 on their iPhone, but have not updated their iPad yet. The user then adds some notes to existing records. Obviously, the user’s iPad will not download these notes since they have not updated to the version of the app that supports that field.

Now, when the user finally installs version 2 of the app on their iPad, I want to ask NSPersistentCloudKitContainer to fetch the notes fields for the records that have been updated. However, I don’t see a way to do this.

Of course, I could get the record ID for the records and download the data from CloudKit myself, then merge it into the local Core Data store. But then I have to manage all the things NSPersistenCloudKitContainer manages for me (errors, completion, etc.).

Does anyone have a solution for this?

Answered by Frameworks Engineer in 678318022

No. NSPersistentCloudKitContainer will do this for you after the migration completes.

If you have a migration where this doesn't occur file a feedback with your various managed object models and we will investigate.

Accepted Answer

No. NSPersistentCloudKitContainer will do this for you after the migration completes.

If you have a migration where this doesn't occur file a feedback with your various managed object models and we will investigate.

NSPersistentCloudKitContainer: How to re-fetch a record from CloudKit?
 
 
Q