本文介绍了使用 Swift PFIdResultBlock 错误解析云的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PFCloud.callFunctionInBackground("hello", withParameters: ["test":"tester"]) {
(response: AnyObject?, error: NSError?) -> Void in
if error == nil {
let responseString = response as? String
print(responseString)
} else {
print(error!.description)
}
}
我收到错误:
无法将(AnyObject?, NSError?) -> Void"类型的值转换为预期的参数类型PFIdResultBlock?"(又名'可选 ()>')
即使我将 添加为!PFIdResultBlock
,错误不会消失.
Even if I add as! PFIdResultBlock
, the error will not go away.
我该如何解决这个问题?
How can I go about fixing this?
我非常感谢你在这方面的帮助!!
I definitely appreciate your help on this one!!
推荐答案
与 Objective-C 不同,在实现闭包(Objective-C 中的 Block)时无需指定变量类型.您只需将代码更改为以下内容:
There is no need to specify the variable types while implementing the closure (Block in Objective-C) unlike Objective-C. You just need to change your code to the following:
PFCloud.callFunction(inBackground: "",
withParameters: ["": ""]) { (response, error) in
if error == nil {
let responseString = response as? String
print(responseString)
} else {
print(error?.localizedDescription)
}
}
这篇关于使用 Swift PFIdResultBlock 错误解析云的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!