解析/ Swift getObjectInBackgroundWithId查询不起作用

问题描述 投票:0回答:3

我正在尝试运行查询以获取ID为背景的对象,但是当我运行方法query.getObjectInBackgroundWithId时,出现了错误消息:

"Cannot invoke 'getObjectInBackgroundWithId' with an argument list of type (string, block: (PFObject!,NSError?) -> Void"

当我使用user.signUpInBackgroundWithBlock时会发生相同的事情,所以我在想也许Xcode在使用'block'时更新了某些功能,现在语法可能有所不同吗?有什么想法吗?

这是我的代码段:

http://imgur.com/1CvfhbU

xcode swift login parse-platform username
3个回答
1
投票

是!谢谢!

getObject的新示例代码是:

query.getObjectInBackgroundWithId("Oaq79bhv53") {
        (gameScore: PFObject?, error: NSError?) -> Void in
        if error == nil && gameScore != nil {
            println(gameScore)
        } else {
            println("error")
        }
    }

0
投票

我知道了!

user.signUpInBackgroundWithBlock{(succeeded: Bool, signUpError: NSError?) -> Void in

0
投票

Swift 4.2:

query.getObjectInBackground(withId: "YourId") { (gameScore, error) in
  if error == nil {
    // Success!
    print(gameScore)
  } else {
   // Fail!
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.