Created
June 20, 2018 12:30
-
-
Save mohammad19991/584a199065173c72ca82afc998381e06 to your computer and use it in GitHub Desktop.
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
//1 | |
let keychain = Keychain(server: domain, protocolType: .https).synchronizable(true) | |
let email = UserDefaults.standard.object(forKey: "account") as? String | |
//2 | |
if let account = email, let password = try? keychain.get(account) { | |
return password | |
}else { | |
//3 | |
keychain.getSharedPassword({ [weak self] (account, password, error) in | |
guard let account = account, let password = password else { return } | |
//4 | |
keychain[account] = password | |
return password | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment