An operation that reports on the changed and deleted records in the specified record zone.


@interface CKFetchRecordChangesOperation : CKDatabaseOperation


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.

To get the most benefit out of a CKFetchRecordChangesOperation object, you must maintain a local cache of the records from the specified zone. Each time you fetch changes from that zone, the server provides a token that identifies your request. With each subsequent fetch request, you initialize the operation object with the token from the previous request, and the server returns only the records that changed since that request.

The blocks you assign to process the fetched records are executed serially on an internal queue managed by the operation. Your blocks must be capable of executing on a background thread, so any tasks that require access to the main thread must be redirected accordingly.

If you assign a completion block to the completionBlock property of the operation object, the completion block is called after the operation executes and returns its results to you. You can use a completion block to perform housekeeping chores related to the operation, but do not use it to process the results of the operation itself. Any completion block you specify should be prepared to handle the failure of the operation to complete its task, whether due to an error or an explicit cancellation.


Initializing the Operation Object

- initWithRecordZoneID:previousServerChangeToken:

Initializes and returns an operation object configured to fetch changes in the specified record zone.

Configuring the Operation Object


The ID of the record zone whose records you want to fetch.


The token that identifies the starting point for retrieving changes.


The fields to fetch for the requested records.


The maximum number of changed records to report with this operation object.

Processing the Operation Results


The block to execute with the contents of a changed record.


The block to execute with the ID of a record that was deleted.


The block to execute when all changes have been reported.


A Boolean value indicating that more results are available.


Inherits From

See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software