SHARE
TWEET

Untitled

a guest Sep 4th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UIKit
  2. class ViewController: UIViewController {
  3.     @IBOutlet weak var usernameTF: UITextField!
  4.     @IBOutlet weak var passwordTF: UITextField!
  5.     @IBOutlet weak var mySwitch: UISwitch!
  6.    
  7.     override func viewDidLoad() {
  8.         super.viewDidLoad()
  9.         mySwitch.isOn = false
  10.     }
  11.  
  12.     @IBAction func loginPressed(_ sender: UIButton) {
  13.         let username = usernameTF.text!
  14.         let password = passwordTF.text!
  15.        
  16.         //Bilgileri kontrol et
  17.         if username == "test" && password == "test" {
  18.             //Switch açıksa bilgileri kaydet
  19.             if mySwitch.isOn == true {
  20.                 let defaults = UserDefaults.standard
  21.                 defaults.set(username, forKey: "userKey")
  22.                 defaults.set(password, forKey: "passKey")
  23.             }
  24.            
  25.             //Anasayfaya git
  26.             performSegue(withIdentifier: "loginSegue", sender: nil)
  27.         }
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top