Search code examples
iosswiftparse-platformobjectidpfuser

How to retrieve ObjectID after PFUser login?


PFUser.logInWithUsernameInBackground(fullName.text, password: password.text) {
(user: PFUser!, error: NSError!) -> Void in

     if user != nil {

       self.loginButton.enabled = false
       self.helpButton.enabled = false

       self.objectID = self.PFUser.objectId
    }
}

I need to the users objectID after they log in. I know how to retrieve the objectID for just a PFObject when when it comes to PFUser I get an error (on the last line of code above). How can I get the id?


Solution

  • You are using self.PFUser.objectId, but I think you mean the user that you get back from the completion block. So try:

    self.objectID = user.objectId
    

    in the last line.