简体   繁体   English

如何在iOS 9的Swift 2中的CloudKit中调用完成块?

[英]How to invoke completion block in CloudKit in Swift 2 in iOS 9?

I did not managed to translate my working iOS8 code snippet into iOS 9 Swift 2 Xcode version 7.0 beta (7A120f). 我没有将有效的iOS8代码片段转换为iOS 9 Swift 2 Xcode 7.0 beta(7A120f)。

My last attempt was: 我最后的尝试是:

saveRecordsOperation.perRecordCompletionBlock {
    (record:CKRecord, recordID:CKRecordID, error:NSError) -> Void in

    print("perRecordCompletionBlock \(record)")
}

But Xcode says: 但是Xcode说:

AppDelegate.swift:929:34: Cannot invoke 'perRecordCompletionBlock' with an argument list of type '((CKRecord, CKRecordID, NSError) -> Void)'

Any idea? 任何想法?

Ok, here is the solution: 好的,这是解决方案:

       saveRecordsOperation.perRecordCompletionBlock = {
            (record:CKRecord?, error:NSError?) -> Void in

            print("perRecordCompletionBlock \(record)")
        }

There where two issues actually: one I introduced while dealing around to find a solution when I desperately added recordID, while the second was we now must use equal sign to pass the code block. 实际上存在两个问题:一个是我在拼命添加recordID时为了寻找解决方案而介绍的,另一个是我们现在必须使用等号来传递代码块。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM