Skip to content

Instantly share code, notes, and snippets.

@airspeedswift
Forked from justin/gist:f8c0a153aa7d7c9595ee
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save airspeedswift/6c7051b427fa60534c41 to your computer and use it in GitHub Desktop.
Save airspeedswift/6c7051b427fa60534c41 to your computer and use it in GitHub Desktop.
import KeychainAPI
let keychain: Keychain = Keychain(service: "com.secondgear.myapp", accessibility: Accessibility.WhenUnlocked)
let userAccount = Account(userName: "justinw@me.com", secret: "lovesecretsexgod")
keychain.add(userAccount)
if let fetchedAccount = keychain.accountFor("justinw@me.com")
{
fetchedAccount.secret = "newpassword"
keychain.update(fetchedAccount)
keychain.remove(fetchedAccount!);
}
else {
// handle failure
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment