Hi
I have CKFetchRecordZoneChangesOperation with a recordZoneChangeTokensUpdatedBlock
recordZoneChangeTokensUpdatedBlock is getting called multiple times.
Inside recordZoneChangeTokensUpdatedBlock, I try to save the records that are received upto that point in time (collected from recordChangedBlock) and save the server change token so that if the operation fails at a later point, re-creating another CKFetchRecordZoneChangesOperation could use the server change token that was cached and need not fetch from scratch.
References:
This approach was explained in
Problem:
The records received upto that point are not in order.
For example:
I have a master and transaction record types.
I receive 5 transaction records without a single master record.
So when I try to save them the records are in an inconsistent state for the app to function.
Note:
When I saved the records, I saved master and transactions records in a single operation and was saved successfully (using CKModifyRecordsOperation)
Workaround:
I can use the fetchRecordZoneChangesCompletionBlock to save the records into the local cache (Core Data), but for a large operation which fetches a lot of changes with multiple change tokens the user has to wait till the operation completes (as opposed to seeing batches of changes)
My Understanding:
- Based on the video and the documentation, I thought the recordChangedBlock would be called sequentially so that in the recordZoneChangeTokensUpdatedBlock we can save the records changes that have accumulated so far and be in a consistent state.
I really hope someone can help me on this as this. Thanks.