篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Swift - CloudKit - 添加保存删除多个记录相关的知识,希望对你有一定的参考价值。
See: http://www.techotopia.com/index.php/An_Introduction_to_CloudKit_Data_Storage_on_iOS_8
A group of record operations may be performed in a single transaction using the
CKModifyRecordsOperation class. This class also allows timeout durations to be specified for
the transaction, together with completion handlers to be called at various stages during the
process. The following code, for example, uses the CKModifyRecordsOperation class to add three
new records and delete two existing records in a single operation. The code also establishes
timeout parameters and implements all three completion handlers. Once the modify operation
object has been created and configured, it is added to the database for execution:
let modifyRecordsOperation = CKModifyRecordsOperation(
recordsToSave: [myRecord1, myRecord2, myRecord3],
recordIDsToDelete: [myRecord4, myRecord5])
modifyRecordsOperation.timeoutIntervalForRequest = 10
modifyRecordsOperation.timeoutIntervalForResource = 10
modifyRecordsOperation.perRecordCompletionBlock = { record, error in
// Called after each individual record operation completes
}
modifyRecordsOperation.perRecordProgressBlock = { record, progress in
// Called to update the status of an indivudual operation
// progress is a Double value indicating progress so far
}
modifyRecordsOperation.modifyRecordsCompletionBlock = {
records, recordIDs, error in
// Called after all of the record operations are complete
}
privateDatabase?.add(modifyRecordsOperation)
以上是关于swift Swift - CloudKit - 添加保存删除多个记录的主要内容,如果未能解决你的问题,请参考以下文章