1

Using the parse user class I am able to store username, password and email, however I wanted to also store the users name and first name so on parse.com under the core dashboard I added two more columns (firstName and LastName).

 func showName(){
    let user = PFUser()
    let name = user["firstName"]
    let lastname = user["lastName"]
    studentName.text = "\(name) \(lastname) "
}

I want to change the studentName to show the real first and last name of the user. How am I able to get this info from Parse.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user278063
  • 66
  • 1
  • 1
  • 10

1 Answers1

0

This has be adapted from swift 1.2, I haven't tested it out for swift 2 to make sure it fully works, but depending on the version of Xcode, Swift and Parse SDK you are using this should work.

func showName() {
  if let user = PFUser.currentUser() {
     self.displayName.text = "\(user["firstName"] as! String)  \(user["lastName"] as! String)"
  }
}
don
  • 186
  • 2
  • 15
  • @user278063 Sorry for this late reply, I have been busy with other projects but here it goes. I have edited my code with a fix to make it work. Go ahead and give it a try; Let me know if it succeeds or any errors you might be faced with. – don Nov 10 '15 at 01:58