Guest User

Untitled

a guest
Mar 28th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import UIKit
  2.  
  3. class LoginViewController: UIViewController {
  4.  
  5. @IBOutlet weak var userNameTextField: UITextField!
  6. @IBOutlet weak var userPasswordTextField: UITextField!
  7.  
  8. override func viewDidLoad() {
  9. super.viewDidLoad()
  10. // Do any additional setup after loading the view.
  11. }
  12.  
  13. override func didReceiveMemoryWarning() {
  14. super.didReceiveMemoryWarning()
  15. // Dispose of any resources that can be recreated.
  16. }
  17.  
  18. @IBAction func loginButtonTapped(_ sender: Any) {
  19.  
  20. let userName = userNameTextField.text;
  21. let userPassword = userPasswordTextField.text;
  22. let userNameStored = UserDefaults.standard.string(forKey: "userName")
  23. let userPasswordStored = UserDefaults.standard.string(forKey: "userPassword")
  24. if(userNameStored == userName){
  25.  
  26. if(userPasswordStored == userPassword){
  27.  
  28. // ログイン!
  29. UserDefaults.standard.set(true, forKey: "isUserLoggedIn")
  30. //UserDefaults.standard.synchronize()
  31. self.dismiss(animated: true, completion:nil)
  32.  
  33. }
  34.  
  35. }
  36.  
  37. }
  38.  
  39. }
Add Comment
Please, Sign In to add comment