Instance Method

saveRecord:completionHandler:

Saves one record asynchronously, with a low priority, to the current database, if the record has never been saved or if it is newer than the version on the server.

Declaration

- (void)saveRecord:(CKRecord *)record completionHandler:(void (^)(CKRecord *record, NSError *error))completionHandler;

Parameters

record

The record to save. This method throws an exception if this parameter is nil.

completionHandler

The block to execute with the results. Your block must be capable of running on any thread of the app and must take the following parameters:

record

The record object you attempted to save.

error

An error object, or nil if the record was saved successfully. Use the information in the error object to determine whether a problem has a workaround.

Discussion

This method saves the record only if it has never been saved before or if it is newer than the version on the server. You cannot use this method to overwrite newer versions of a record on the server.

This method saves the record with a low priority, which may cause the task to execute after higher-priority tasks. To save records more urgently, create a CKModifyRecordsOperation object with the desired priority. You can also use that operation object to save multiple records simultaneously.

See Also

Accessing Records

- fetchRecordWithID:completionHandler:

Fetches one record asynchronously, with a low priority, from the current database.

- deleteRecordWithID:completionHandler:

Deletes the specified record asynchronously, with a low priority, from the current database.