parsingSwift IOS – PFCloud callFunctionInBackgroundselect器未被调用

当我从正常调用PFcloud函数返回正确的计数如何,当我调用select器,select器callback函数不会被触发,

欣赏是否有任何可以指向我什么是我的代码中的错误。

工作模块 – 成功打印计数

PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], block: { (result: AnyObject!, error: NSError!) -> Void in if ( error === nil) { NSLog("Booking Count call back: \(result) ") } else if (error != nil) { NSLog("error in helloWorld: \(error.userInfo)") } }) 

不工作块(select器) – select器function未被调用

  PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], target: self, selector: "block:") func block (result: AnyObject!, error: NSError!) { if ( error === nil) { NSLog("Booking Count from Block: \(result) ") } else if (error != nil) { NSLog("error in helloWorld: \(error.userInfo)") } } 

题:

我需要有人来强调我的写入select器function的错误,因为select器function没有被调用。

谢谢

你的方法有两个参数,所以你需要一个像blockWithResult:error:这样的select器blockWithResult:error:

你没有使用正确的Swift语法作为select器。 试试这个:

 PFCloud.callFunctionInBackground(CloudFunctions.getBookingCount, withParameters: ["camp": "pmAwLDTNc6"], target: self, selector: Selector("block:error:")) func block(result: AnyObject!, error: NSError!) { if ( error === nil) { NSLog("Booking Count from Block: \(result) ") } else if (error != nil) { NSLog("error in helloWorld: \(error.userInfo)") } }