Skip to content

Instantly share code, notes, and snippets.

@jen2
Created May 8, 2017 00:23
Show Gist options
  • Save jen2/3e45eed9eb14ff1f45a572136a85b77b to your computer and use it in GitHub Desktop.
Save jen2/3e45eed9eb14ff1f45a572136a85b77b to your computer and use it in GitHub Desktop.
"Securing user data with Keychain for iOS" savePasswordButtonTapped implementation.
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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment