KeyValueData
用来存储 Key-Value 型数据。可针对不同情况使用不同的后端存储。
Manage key-value data with same protocol, for kinds of backends.
Example
// Load/Create data
var _dataInKeyChain: KeyValueData = KeyValueDictionaryInKeychain(withKey: "account")
var _dataInUserDefaults: KeyValueData = KeyValueDictionaryInUserDefaults(withKey: "account")
// Data in => NSHomeDirectory()+"/Documents/\(withKey).plist"
var _dataInPlist: KeyValueData = KeyValueDictionaryInDocumentsPlist(withKey: "account")
// Data in => NSHomeDirectory()+"/Documents/KeyValue.sqlite", table: withKey
var _dataInSQLite: KeyValueData = KeyValueDictionaryInSqlite(withKey: "account")
// Data in iCloud KV storage with key: withKey
var _dataIniCloud: KeyValueData = KeyValueDictionaryIniCloud(withKey: "account")
// set/get data from KV
_data["accountid"] = "12345678"
let id = _data["accountid"] as! String
// write data to disk
// this is not necessary for KeyChain/SQLite
_data.sync()
Requirements
- iOS 14.0+
Installation
可通过CocoaPods安装:
KeyValueData is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "KeyValueData"
Author
License
KeyValueData is available under the MIT license. See the LICENSE file for more info.