Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. let currentUser = PFUser.currentUser()?.username
  2.  
  3. if currentUser == nil {
  4. user.signUpInBackgroundWithBlock() {(success, error) -> Void in
  5. if success {
  6. print("successfully saved")
  7. } else {
  8.  
  9. do
  10. {
  11. try PFUser.logInWithUsername(username, password: emailData)
  12. }
  13. catch
  14. {
  15. print(error)
  16. }
  17. self.updateUI()
  18. }
  19. }
  20. }
  21. }
  22.  
  23.  
  24. func updateUI () {
  25.  
  26. if let userFirstName = PFUser.currentUser()?["firstName"] as? String {
  27. firstNameLabel.text = userFirstName
  28. } else {
  29. self.firstNameLabel.text = ""
  30. }
  31.  
  32. if let userLastName = PFUser.currentUser()?["lastName"] as? String {
  33. lastNameLabel.text = userLastName
  34. } else {
  35. self.lastNameLabel.text = ""
  36. }
  37.  
  38. if let userPicture = PFUser.currentUser()?["picture"] as? String,
  39. url = NSURL(string: userPicture),
  40. data = NSData(contentsOfURL: url),
  41. image = UIImage(data: data)
  42. {
  43. profilePictureImageView?.image = image
  44.  
  45. }
  46. else {
  47. self.profilePictureImageView.image = nil
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement