CKModifyRecordsOperation 完成 Swift 2.0
Posted
技术标签:
【中文标题】CKModifyRecordsOperation 完成 Swift 2.0【英文标题】:CKModifyRecordsOperation completion Swift 2.0 【发布时间】:2015-08-31 12:56:51 【问题描述】:我有以下代码,但在使用 Xcode 7 和 Swift 2.0 构建时显示错误
错误是Cannot call value non-function type (([CKRecord]?, [CKRecordID]?, NSError?) -> Void)?
谢谢
let saveRecordsOperation = CKModifyRecordsOperation()
var ckRecordsArray = [CKRecord]()
// set values to ckRecordsArray
saveRecordsOperation.recordsToSave = ckRecordsArray
saveRecordsOperation.savePolicy = .IfServerRecordUnchanged
saveRecordsOperation.modifyRecordsCompletionBlock savedRecords, deletedRecordIDs, error in
// deal with conflicts
// set completionHandler of wrapper operation if it's the case
if saveRecordsOperation.finished == true
database.addOperation(saveRecordsOperation)
【问题讨论】:
【参考方案1】:saveRecordsOperation.modifyRecordsCompletionBlock savedRecords, deletedRecordIDs, error in
应该是
saveRecordsOperation.modifyRecordsCompletionBlock = savedRecords, deletedRecordIDs, error in
【讨论】:
以上是关于CKModifyRecordsOperation 完成 Swift 2.0的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 CKModifyRecordsOperation.perRecordProgressBlock 更新进度
为啥CKModifyRecordsOperation批量删除CloudKit中的记录不删除记录?
CKModifyRecordsOperation 完成 Swift 2.0
CloudKit:使用 CKModifyRecordsOperation 保存记录时出错
在 CKModifyRecordsOperation 中保存 CKRecord 和 CKShare 时出错
调用 CKModifyRecordsOperation 时,出现错误:CKError: "Invalid Arguments" (12)。这是啥意思,我能做些啥呢?