modifyRecords(saving:deleting:savePolicy:atomically:)
Modifies the specified records and returns the results to an awaiting caller.
Declaration
func modifyRecords(saving recordsToSave: [CKRecord], deleting recordIDsToDelete: [CKRecord.ID], savePolicy: CKModifyRecordsOperation.RecordSavePolicy = .ifServerRecordUnchanged, atomically: Bool = true) async throws -> (saveResults: [CKRecord.ID : Result<CKRecord, any Error>], deleteResults: [CKRecord.ID : Result<Void, any Error>])Parameters
- recordsToSave:
The records to save.
- recordIDsToDelete:
The identifiers of the records to permanently delete.
- savePolicy:
The policy to use when modifying existing records. For possible values, see Recordsavepolicy.
- atomically:
If True, the entire operation fails if CloudKit can’t modify one or more of the specified records; otherwise, CloudKit reports individual failures in the returned tuple. Atomic changes are only applicable in record zones that have the Atomic capability.
Return Value
A tuple with the following named elements:
saveResultsA dictionary of saved records. The dictionary uses the identifiers of the records you specify in
recordsToSaveas its keys. The value of each key is a Result that contains either the corresponding modified record (as it appears on the server), or an error that describes why CloudKit can’t modify that record.deleteResultsA dictionary of deleted records. The dictionary uses the identifiers you specify in
recordIDsToDeleteas its keys. The value of each key is a Result that contains either Void to indicate a successful deletion, or an error that describes why CloudKit can’t delete that record.
Discussion
Deleting records may cause additional deletions if other records in the database reference the deleted records. CloudKit doesn’t provide the identifiers of any additional records it deletes. This method throws an error if the request fails, such as when the network is unavailable or the device doesn’t have an active iCloud account, or when atomically is true and one or more of the specified changes fail; otherwise, the returned tuple includes any individual record errors.
For information on a more configurable way to modify records, see CKModifyRecordsOperation.