Search code examples
swiftparse-platformpfobjectpfuser

Editing fields in the PFUser object is not working


I would like to know why I am not able to update or add any fields to my current user's object.

Using this code:

PFUser.currentUser()!.username = "hi"

does not affect my object whatsoever in Parse, neither does any setObject call. However, when I NSLog the username, it will print what I just set it to from that line above...


Solution

  • Let's say you have a textfield that gets the new username.

    No need to query back from the username, Just override it with the newusername

    var newusername = textfield.text
    var user = PFUser()
    user.username = newusername
    user.saveInBackgroundWithBlock { (success:Bool, error:NSError?) -> Void in
        if error == nil
        {
          //yay it was saved
        }
    }