Mansour
Mansour

Reputation: 535

Add add an object to a PFUser

I try to add an object to a PFUser using the following code:

@IBAction func ButtonPressed(sender: AnyObject) {

    var user = PFUser.currentUser()
    user.addObject("test", forKey: "surname")}

But unfortunately I get no value on my Parse Dashboard. I don't understand why Thanks

Upvotes: 0

Views: 290

Answers (1)

Logan
Logan

Reputation: 53112

Did you save?

var user = PFUser.currentUser()
user.addObject("test", forKey: "surname")}
user.saveInBackground()

Also a couple notes. You could use a let here as your user variable shouldn't change its pointer, and subscript syntax is more readable (my opinion) :)

let user = PFUser.currentUser()
user["test"] = "surname"
user.saveInBackground()

Upvotes: 1

Related Questions