swiftparse-platformpfquerypfobject

Why is PFObject not saving in background?


Here is my code, I'm simply trying to adjust the value of an object in the PFUser class.

var query = PFUser.query()
let userStr = "exampleuser"
query.whereKey("username", equalTo: userStr)
    
query.getFirstObjectInBackgroundWithBlock{(object: PFObject!, error: NSError!) -> Void in
        
        object.incrementKey("count")
        object.saveInBackground()
        
        println(object["count"]) //Prints correct value
}

As you can see by the comment, object["count"] returns the new, updated value, but in Parse, nothing.


Solution

  • Try changing the save to object.saveInBackgroundWithBlock(...) and see if you are getting an error. It's quite likely that the current user does not have permission to update the user object selected in the query.

    The default ACL for a PFUser object only allows the owner to edit.