Guest User

Untitled

a guest
Nov 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. //
  2. // RegisterPageViewController.swift
  3. // UserLoginandRegistration
  4. //
  5. // Created by Iyah Chulo on 17/11/2017.
  6. // Copyright © 2017 Iyah Chulo. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class RegisterPageViewController: UIViewController {
  12.  
  13. @IBOutlet weak var userEmailTextField: UITextField!
  14. @IBOutlet weak var userPasswordTextField: UITextField!
  15. @IBOutlet weak var ReenterPasswordTextField: UITextField!
  16.  
  17.  
  18.  
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21.  
  22. // Do any additional setup after loading the view.
  23. }
  24.  
  25. override func didReceiveMemoryWarning() {
  26. super.didReceiveMemoryWarning()
  27. // Dispose of any resources that can be recreated.
  28. }
  29.  
  30. @IBAction func RegisterButtonTapped(_ sender: Any) {
  31.  
  32. let userEmail = userEmailTextField.text;
  33. let userPassword = userPasswordTextField.text;
  34. let userReenterPassword = ReenterPasswordTextField.text;
  35.  
  36. // Check for empty fields
  37. if((userEmail?.isEmpty)! || (userPassword?.isEmpty)! ||
  38. (userReenterPassword?.isEmpty)!)
  39.  
  40. {
  41.  
  42. func displayAlertMessage(userMessage: String) { let myAlert = UIAlertController(title:"Alert", message: userMessage, preferredStyle:
  43. UIAlertControllerStyle.alert);
  44.  
  45. let okAction = UIAlertAction(title:"Ok", style:
  46. UIAlertActionStyle.default, handler:nil)
  47.  
  48. myAlert.addAction(okAction);
  49.  
  50. self.present(myAlert, animated: true,
  51. completion:nil)
  52. }
  53.  
  54. //Check if passwords match
  55. if(userPassword != userReenterPassword)
  56. {
  57.  
  58. // Display an alert message
  59.  
  60. displayAlertMessage(userMessage: "Passwords do not match")
  61.  
  62. return;
  63.  
  64. }
  65.  
  66.  
  67. // Store data
  68.  
  69. UserDefaults.standard.set(userEmail, forKey:"userEmail")
  70. UserDefaults.standard.set(userEmail, forKey:"userPassword")
  71. UserDefaults.standard.synchronize()
  72.  
  73. // Display alert message with confirmation
  74. var myAlert = UIAlertController(title:"Alert", message: "Registration is successful.Thank you!", preferredStyle:
  75. UIAlertControllerStyle.alert);
  76. let okAction = UIAlertAction(title:"Ok", style:
  77. UIAlertActionStyle.default) { action in
  78. self.dismiss(animated: true, completion:nil)
  79.  
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. }
  90.  
  91. }
Add Comment
Please, Sign In to add comment