BlueIntent 0.13.0

BlueIntent 0.13.0

Maintained by ZhiFei Qiu.



BlueIntent 0.13.0

  • By
  • qiuzhifei

BlueIntent

CI Status Version License Platform

Example

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"

Requirements

Installation

BlueIntent is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'BlueIntent'

Author

qiuzhifei, [email protected]

License

BlueIntent is available under the MIT license. See the LICENSE file for more info.