Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // RegisterPageViewController.swift
- // UserLoginandRegistration
- //
- // Created by Iyah Chulo on 17/11/2017.
- // Copyright © 2017 Iyah Chulo. All rights reserved.
- //
- import UIKit
- class RegisterPageViewController: UIViewController {
- @IBOutlet weak var userEmailTextField: UITextField!
- @IBOutlet weak var userPasswordTextField: UITextField!
- @IBOutlet weak var ReenterPasswordTextField: UITextField!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- @IBAction func RegisterButtonTapped(_ sender: Any) {
- let userEmail = userEmailTextField.text;
- let userPassword = userPasswordTextField.text;
- let userReenterPassword = ReenterPasswordTextField.text;
- // Check for empty fields
- if((userEmail?.isEmpty)! || (userPassword?.isEmpty)! ||
- (userReenterPassword?.isEmpty)!)
- {
- func displayAlertMessage(userMessage: String) { let myAlert = UIAlertController(title:"Alert", message: userMessage, preferredStyle:
- UIAlertControllerStyle.alert);
- let okAction = UIAlertAction(title:"Ok", style:
- UIAlertActionStyle.default, handler:nil)
- myAlert.addAction(okAction);
- self.present(myAlert, animated: true,
- completion:nil)
- }
- //Check if passwords match
- if(userPassword != userReenterPassword)
- {
- // Display an alert message
- displayAlertMessage(userMessage: "Passwords do not match")
- return;
- }
- // Store data
- UserDefaults.standard.set(userEmail, forKey:"userEmail")
- UserDefaults.standard.set(userEmail, forKey:"userPassword")
- UserDefaults.standard.synchronize()
- // Display alert message with confirmation
- var myAlert = UIAlertController(title:"Alert", message: "Registration is successful.Thank you!", preferredStyle:
- UIAlertControllerStyle.alert);
- let okAction = UIAlertAction(title:"Ok", style:
- UIAlertActionStyle.default) { action in
- self.dismiss(animated: true, completion:nil)
- }
- }
- }
Add Comment
Please, Sign In to add comment