iOS Keychain的Swift封裝:Locksmith
一個強大,面向協議的庫,用于在Swift中能夠使用 iOS Keychain 。
Locksmith與其它keychain封裝的不同之處在于?
- Locksmith’s API is both super-simple and deeply powerful
- Provides access to all of the keychain’s metadata in a type-useful way viaResultTypeprotocols—save anNSDate, get anNSDateback (without typecasting!)
- Add functionality to your existing types for free
- Useful enums and Swift-native types
Installation
CocoaPods
Locksmith is available through CocoaPods. To install Locksmith for Swift 2, simply add the following line to your Podfile:
pod 'Locksmith'
Swift 1.2 support is available via the1.2.2branch.
Quick start
Save data
try Locksmith.saveData(["some key": "some value"], forUserAccount: "myUserAccount")
Load data
let dictionary = Locksmith.loadDataForUserAccount("myUserAccount")
Update data
- as well as replacing existing data, this writes data to the keychain if it does not exist already
try Locksmith.updateData(["some key": "another value"], forUserAccount: "myUserAccount")
Delete data
try Locksmith.deleteDataForUserAccount("myUserAccount")
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!