CKModifyRecordsOperation完成Swift 2.0

时间:2015-08-31 12:56:51

标签: ios swift2 xcode7 completion-block ckmodifyrecordsoperation

我有以下代码,但在使用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 个答案:

答案 0 :(得分:7)

saveRecordsOperation.modifyRecordsCompletionBlock { savedRecords, deletedRecordIDs, error in

应该是

saveRecordsOperation.modifyRecordsCompletionBlock = { savedRecords, deletedRecordIDs, error in