Contents

modifyRecordZones(saving:deleting:completionHandler:)

Modifies the specified record zones and delivers the results to a completion handler.

Declaration

@preconcurrency func modifyRecordZones(saving recordZonesToSave: [CKRecordZone], deleting recordZoneIDsToDelete: [CKRecordZone.ID], completionHandler: @escaping  @Sendable (Result<(saveResults: [CKRecordZone.ID : Result<CKRecordZone, any Error>], deleteResults: [CKRecordZone.ID : Result<Void, any Error>]), any Error>) -> Void)

Parameters

  • recordZonesToSave:

    The record zones to save.

  • recordZoneIDsToDelete:

    The identifiers of the record zones to permanently delete.

  • completionHandler:

    The closure to execute after CloudKit processes the changes.

Discussion

The completion handler takes a single Result parameter that contains either a tuple, or an error if the request fails. For example, when the network is unavailable or the device doesn’t have an active iCloud account.

When present, the tuple contains the following named elements:

saveResults

A dictionary of saved record zones. The dictionary uses the identifiers of the record zones you specify in recordsZonesToSave as its keys. The value of each key is a Result that contains either the corresponding modified record zone (as it appears on the server), or an error that describes why CloudKit can’t modify that record.

deleteResults

A dictionary of deleted record zones. The dictionary uses the identifiers you specify in recordZoneIDsToDelete as 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 zone.

For information on a more configurable way to modify record zones, see CKModifyRecordZonesOperation.

See Also

Modifying Record Zones