An operation used to retrieve records from CloudKit.


@interface CKFetchRecordsOperation : CKDatabaseOperation


Use this operation to retrieve the entire contents of each record or only a subset of its contained values. As records become available, the operation object reports progress about the state of the operation to several different blocks, which you can use to process the results.

Fetching records is a common use of CloudKit, even if your app does not cache record IDs locally. For example, when you fetch a record related to the current record through a CKReference object, you use the ID in the reference to perform the fetch.

The blocks you assign to process the fetched records are executed serially on an internal queue managed by the fetch records 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.

In addition to data records, a fetch records operation can fetch the current user record. The fetchCurrentUserRecordOperation method returns a specially configured operation object that retrieves the current user record. That record is a standard CKRecord object whose contents are empty initially. You can add data to the user record and save it as needed. Because a discoverable user record can be accessed by other users of the app, never store sensitive personal information such as passwords in the user record. If you must store sensitive information about a user, do so in a separate record that is accessible only to that user.

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

- initWithRecordIDs:

Initializes and returns an operation object configured to fetch the records with the specified IDs.

Getting the Current User Record

+ fetchCurrentUserRecordOperation

Returns an operation object that can be used to fetch the current user record.

Configuring the Operation Object


The array of IDs corresponding to the records to fetch.


The fields to fetch for the requested records.

Processing the Operation Results


The block to execute with progress information for individual records.


The block to execute when the results of a single record are available.


The block to execute after all records are fetched or have received appropriate errors.


Inherits From

See Also

Fetching Records


An operation that fetches record changes across the given record zone.


An operation used to retrieve zones from a database in CloudKit.


An object that identifies a specific version of a record.