Search code examples
iosswiftparse-platformpfuser

How to retrieve objectID from PFUser username query?


I ask the user to input their username. I then search the User class in Parse for their "account" and retrieve it. I can get the objectID and a bunch of other parameters into user but when I try to just isolate objectID I get errors...

var query = PFUser.query()
query.whereKey("username", equalTo: self.userText.text)
query.findObjectsInBackgroundWithBlock {
   (user: [AnyObject]!, error: NSError!) -> Void in

   println (user) //This gives me all the parameters.
   println (user.objectId) //Gives me an error.
}

The error I get is "PFUser.Type does not have a member named objectId" and "[AnyObject] does not have a member named objectId"


Solution

  • useris an array here, try println (user[0].objectId)