ios - 无法使用类型的参数列表调用 'getObjectInBackgroundWithId'

标签 ios swift parse-platform xcode7

我收到以下错误:

cannot invoke 'getObjectInBackgroundWithId' with an argument list of type

使用以下代码行:

query.getObjectInBackgroundWithId("Parse Object id is here") 

完整的代码行是:

func CallData(){
       var query : PFQuery = PFQuery(className: "QuestionsandAnswers")
       query.getObjectInBackgroundWithId("Parse Object id is here") {
            (ObjectHolder : PFObject!, error: NSError!) -> Void in
            if (error == nil) {
                self.Question = ObjectHolder.valueForKey("Question") as! String
                self.Answers = ObjectHolder.valueForKey("Answers") as! Array
                self.Answer = ObjectHolder.valueForKey("Answer") as! String

                if(self.Answers.count > 0){
                    self.QuestionLabel.text = self.Question

                }

有人有什么建议吗?我使用的是xcode7

最佳答案

在 Swift 2 中,该方法的方法签名已更改。

使用以下内容:

query.getObjectInBackgroundWithId("Parse Object id is here") {
        (ObjectHolder: PFObject?, error: NSError?) -> Void in

        if (error == nil) {
            self.Question = ObjectHolder.valueForKey("Question") as! String
            self.Answers = ObjectHolder.valueForKey("Answers") as! Array
            self.Answer = ObjectHolder.valueForKey("Answer") as! String

            if(self.Answers.count > 0){
                self.QuestionLabel.text = self.Question
            }

参见doc here .

关于ios - 无法使用类型的参数列表调用 'getObjectInBackgroundWithId',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32707054/

相关文章:

ios - UIViewController 忽略了一些 Controller (iOS 4.3 及更高版本)

ios - XCode: Storyboard 在元素之间添加了额外的空间?

ios - CoreLocation 为空,应用程序在启动时崩溃

ios - 解析 iOS - 删除方法返回 true 但记录未删除

ios - 如何将自动布局与容器转换一起使用?

iphone - 我怎样才能在 iPhone 应用程序中捕获所有异常

iOS Swift - 谷歌登录后无法访问 SWRevealViewController

swift - 如何倒计时 Swift

ios - 在 Swift 中获取与解析云代码错误的关系

ios - 解析推送通知:“无效 token :用户可能已卸载了该应用程序”