swift / parse getObjectInBackgroundWithId查询不起作用

时间:2015-08-01 11:51:05

标签: ios swift parse-platform

我尝试使用ReportFieldValue的{​​{1}}方法,但会抛出此错误:

getObjectInBackgroundWithId

我写了以下代码:

PFObject

任何帮助?

1 个答案:

答案 0 :(得分:0)

您必须使用getObjectInBackgroundWithId

let query = PFQuery(className: "posts")
query.getObjectInBackgroundWithId("kk") { (objects, error) -> Void in

}

OR

let query = PFQuery(className: "posts")
query.getObjectInBackgroundWithId("kk") { (objects:PFObject?, error:NSError?) -> Void in

}

更改对象

let query = PFQuery(className: "posts")
query.getObjectInBackgroundWithId("kk") { (objects, error) -> Void in
    let testObj = objects?.first as! PFObject
    testObj.setObject(26, forKey: "pLikes")
    testObj.saveInBackgroundWithBlock { (succeeded, error) -> Void in
        if succeeded {
            println("Object Uploaded")
        } else {
            println("Error: \(error) \(error!.userInfo!)")
        }
    }
}