Contents

CKModifyRecordsOperation

An operation that modifies one or more records.

Declaration

class CKModifyRecordsOperation

Mentioned in

Overview

After modifying the fields of a record, use this operation to save those changes to a database. You also use this operation to delete records permanently from a database.

If you’re saving a record that contains a reference to another record, set the reference’s action to indicate if the target record’s deletion should cascade to the saved record. This helps avoid orphaned records in explicit record hierarchies. When creating two new records that have a reference between them, use the same operation to save both records at the same time. During a save operation, CloudKit requires that the target record of the parent reference, if set, exists in the database or is part of the same operation; all other reference fields are exempt from this requirement.

When you save records, the value in the savePolicy property determines how to proceed when CloudKit detects conflicts. Because records can change between the time you fetch them and the time you save them, the save policy determines whether new changes overwrite existing changes. By default, the operation reports an error when there’s a newer version on the server. You can change the default setting to permit your changes to overwrite the server values wholly or partially.

The handlers you assign to monitor progress of the operation execute serially on an internal queue that the operation manages. You must provide handlers capable of executing on a background thread, so any tasks that require access to the main thread must redirect accordingly.

If you assign a completion handler to the completionBlock property of the operation, CloudKit calls it after the operation executes and returns the results. Use the completion handler to perform any housekeeping tasks for the operation, but don’t use it to process the results of the operation. The completion handler you provide should manage any failures of the operation, whether due to an error or an explicit cancellation.

Topics

Creating a Modify Record Operation

Configuring the Modify Record Operation

Processing the Modify Record Results

Instance Properties

See Also

Transactions