Contents

save(_:completionHandler:)

Saves a specific record.

Declaration

func save(_ record: CKRecord, completionHandler: @escaping  @Sendable (CKRecord?, (any Error)?) -> Void)
func save(_ record: CKRecord) async throws -> CKRecord

Parameters

  • record:

    The record to save.

  • completionHandler:

    The closure to execute after CloudKit saves the record.

Discussion

The completion handler takes the following parameters:

  • The saved record (as it appears on the server), or nil if there’s an error.

  • An error if a problem occurs, or nil if CloudKit successfully saves the record.

The save succeeds only when the specified record is new, or is a more recent version than the one on the server.

For information on a more convenient way to save records, see modifyRecords(saving:deleting:savePolicy:atomically:).

See Also

Modifying Records