Contents

CKError

A type that describes a CloudKit error.

Declaration

struct CKError

Mentioned in

Overview

CloudKit provides operations that faciliate moving data between your app and iCloud. There are also convenience methods in CKContainer and CKDatabase that provide similar functionality. If an operation or method fails to complete its task, CloudKit provides detailed error information that you can use to recover. A failure might be due to network or server conditions, or because of conflicts between local and remote data. For a list of possible reasons, see CKError.Code.

If you receive an error, cast it to an instance of CKError to access additional information that CloudKit provides. For example, if the error code is requestRateLimited, you can use the retryAfterSeconds property to determine how long you must wait before you retry the operation or method.

Batch operations, such as CKModifyRecordsOperation, can complete with a partialFailure error. This means only a subset of the operation’s changes succeed. Use the partialErrorsByItemID property to access a dictionary that maps items that CloudKit can’t process to errors that describe those failures. You can then handle each error independently.

If you attempt to save a record and the server’s version of that record is newer, CloudKit returns a serverRecordChanged error. Use the ancestorRecord, clientRecord, and serverRecord properties to resolve the conflict. Make sure you merge any changes into serverRecord because that version contains the most recent change tag.

Topics

Getting Error Codes

Getting Partial Errors

Getting Conflicted Records

Getting Retry Information

Type Properties

See Also

Errors