BlueIntent 0.13.0

BlueIntent 0.13.0

仇志飞 维护。



BlueIntent 0.13.0

  • 作者:
  • qiuzhifei

BlueIntent

CI Status Version License Platform

示例

DB 存储

FMDB 封装为 KV 存储

使用

cocoapods

pod 'BlueIntent/DB'

shared db

路径 Documents/blueintent/db/shared.db,不与iCloud同步

let db = BlueIntent.DB.shared

db["key", String.self] = "value"
let value = BlueIntent.DB.shared["key", String.self]

自定义 db

let documentDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let dbPath = documentDir.appendingPathComponent("blueintent/db/shared.db")
let db = BlueIntent.DB(url: dbPath, isExcludedFromBackup: true)

db["key", String.self] = "value"
let value = BlueIntent.DB.shared["key", String.self]

使用属性装饰器

# 自定义 DB Class
struct CustomDB {
    @BlueIntent.DB.DBWrapper("name", default: "name", db: .custom)
    static var name
    
    @BlueIntent.DB.DBWrapper("age", db: .custom)
    static var age: Int?
    
    @BlueIntent.DB.DBWrapper({"uid" + "\(Date().timeIntervalSince1970)"}, db: .custom)
    static var uid: String?
}

CustomDB.name = "name1"

需求

安装

BlueIntent可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中

pod 'BlueIntent'

作者

qiuzhifei, [email protected]

许可协议

BlueIntent采用MIT许可协议。有关更多信息,请参阅LICENSE文件。