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