Guest User

Untitled

a guest
Jan 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. func checkPassword() {
  2.  
  3. let alert = UIAlertController(title: "Password", message: "What is your password", preferredStyle: .alert)
  4.  
  5. let authenticateAction = UIAlertAction(title: "Authenticate", style: .default) { (action) in
  6.  
  7. guard let textfield = alert.textFields?.first,
  8. let password = textfield.text else {
  9. return
  10. }
  11.  
  12. if (password == "alice so cute") {
  13.  
  14. self.infoLabel.text = "Password successful"
  15. self.performSegue(withIdentifier: "secret", sender: self)
  16.  
  17. } else {
  18.  
  19. self.infoLabel.text = "incorrect password"
  20. }
  21.  
  22. }
  23.  
  24. let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
  25.  
  26. alert.addTextField(configurationHandler: nil)
  27.  
  28. alert.addAction(cancelAction)
  29. alert.addAction(authenticateAction)
  30.  
  31. present(alert,animated: true)
  32. }
Add Comment
Please, Sign In to add comment