Skip to content

Instantly share code, notes, and snippets.

@jedmund
Created September 3, 2016 19:22
Show Gist options
  • Save jedmund/63082a2d15e69fff7519180019348d14 to your computer and use it in GitHub Desktop.
Save jedmund/63082a2d15e69fff7519180019348d14 to your computer and use it in GitHub Desktop.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "10.0"
use_frameworks!
target 'Locksmith-test' do
pod 'Locksmith',
:git => 'https://github.com/pascalfribi/Locksmith.git',
:branch => 'swift-3.0'
end
Locksmith: Saving data to keychain...
Locksmith: Receiving data from keychain...
Locksmith: Data received from keychain: nil
import UIKit
import Locksmith
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let data: [String: Any] = ["username": "myUsername"]
let account: String = "myUserAccount"
let service: String = "myService"
do {
print("Locksmith: Saving data to keychain...")
try Locksmith.saveData(data: data, forUserAccount: account, inService: service)
print("Locksmith: Receiving data from keychain...")
let result = Locksmith.loadDataForUserAccount(userAccount: account, inService: service)
print("Locksmith: Data received from keychain: \(result)")
} catch let error {
print("Locksmith: Error! \(error.localizedDescription)")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment