Created
May 8, 2017 00:25
-
-
Save jen2/ca5d97b3d6fde906e279800ff12edee4 to your computer and use it in GitHub Desktop.
"Securing user data with Keychain for iOS" retrievePasswordButtonTapped implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SwiftKeychainWrapper | |
class ViewController: UIViewController { | |
@IBOutlet weak var passwordTextField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
@IBAction func savePasswordButtonTapped(_ sender: UIButton) { | |
if let password = passwordTextField.text { | |
let saveSuccessful: Bool = KeychainWrapper.standard.set(password, forKey: "userPassword") | |
print("Save was successful: \(saveSuccessful)") | |
self.view.endEditing(true) | |
} | |
} | |
@IBAction func retrievePasswordButtonTapped(_ sender: UIButton) { | |
let retrievedPassword: String? = KeychainWrapper.standard.string(forKey: "userPassword") | |
print("Retrieved passwork is: \(retrievedPassword!)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment