KeyValueData 1.5.0

KeyValueData 1.5.0

测试已测试
语言编程语言 SwiftSwift
许可 MIT
发布最后发布2021年2月
SPM支持 SPM

Alfred Gao 维护。



 
依赖
KeychainAccess~> 4
SQLite.swift~> 0.12
 

  • 作者:
  • Alfred Gao

KeyValueData

CI Status Version License Platform

用于存储 Key-Value 型数据的 Utility。可根据不同的需求使用不同的后端存储。

通过相同的协议管理不同后端的关键值数据。

示例

// 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()

需求

  • iOS 14.0+

安装

可以通过 CocoaPods 安装:

KeyValueData 通过 CocoaPods 提供。要安装它,请在 Podfile 中添加以下行:

pod "KeyValueData"

作者

高阿尔弗雷德[email protected]

许可证

KeyValueData 在MIT许可证下可用。更多信息请查看LICENSE文件。