Search code examples
ioscloudkitckfetchrecordchangesopera

Which records will be downloaded when CKFetchRecordChangesOperation will called with nil token?


Will CKFetchRecordChangesOperation retrieve all records from container?

I hoped it will download all my records, since I added many to different record types, but I get no one. I've initialised it with nil token.

reference says: A CKFetchRecordChangesOperation object reports on the changed and deleted records in the specified record zone. Use this type of operation object to optimize fetch operations for locally managed sets of records. Specifically, use it when you maintain a local cache of your record data and need to synchronize that cache periodically with the server.

I even runned CKFetchRecordChangesOperation from different device to exclude the case only changes performed on other devices is returned.


Solution

  • CKFetchRecordChangesOperation has nothing to do with CKSubscription. Instead it will just return all the changes to all recordTypes.

    The documentation says this about the change token:

    The change token from a previous fetch operation. This is the token passed to your fetchRecordChangesCompletionBlock handler during a previous fetch operation. Use this token to limit the returned data to only those changes that have occurred since you last made the same fetch request. If you specify nil for this parameter, the operation object fetches all records and their contents.

    So you will just get all the records.