如何在Parse上更新对象

时间:2016-11-19 06:40:26

标签: ios swift parse-platform swift2 parse-server

我正在尝试更新Parse中已经在类中的对象,但是,虽然没有错误,但是对象没有被更新。 这就是我的代码。

let query = PFQuery(className: "Requests")
query.whereKey("username", equalTo: request.username)
query.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in
    if error != nil {
        print("Error finding a request")
    } else {
        if let objects = objects {
            for object in objects {
                query.getObjectInBackgroundWithId(object.objectId!, block: {(object:PFObject?, error:NSError?) -> Void in
                    if error != nil {
                        print("Error getting object a request")
                    } else if let object = object{
                        //upadate db
                        object["response"] = "True"
                        object.saveInBackground()
                    }
                })
            }
        }
    }
})

0 个答案:

没有答案