Breeze 0.0.1

Breeze 0.0.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2014年12月
SPM支持 SPM

André Lind 维护。



Breeze 0.0.1

Breeze

Swift 编写的轻量级 CoreData 管理器

Breeze 从 MagicalRecordNimble 中汲取了许多灵感和启发

  • 轻量级且易于设置和使用
  • 一行代码即可在数据库中查找第一个/任意对象
  • 支持 iCloud
  • 仅使用主和背景上下文进行简单架构

安装

然后,将 “Breeze.h” 导入您的 .pch 文件

设置

首先,设置本地或 iCloud 存储

if BreezeStore.iCloudAvailable() {
    BreezeStore.setupiCloudStoreWithContentNameKey("iCloudTestContentName", localStoreName: "iCloudTest", transactionLogs: "iCloud_transactions_logs")
} else {
    BreezeStore.setupStoreWithName("Test", type: NSSQLiteStoreType, options: [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true])
}

保存

BreezeStore.saveInBackground { contextType -> Void in
    let car = Car.createInContextOfType(contextType)
    car.color = UIColor.blueColor()
}

查找

通过属性查找单个对象

let car = Car.findFirst(attribute: "myAttribute", value: 1, contextType: BreezeContextType.Main)

或通过谓词查找

let car = Car.findFirst(predicate: myPredicate, sortedBy: "anotherAttribute", ascending: false, contextType: BreezeContextType.Main)

同样地,通过属性查找所有对象

let cars = Car.findAll(attribute: "myAttribute", value: 1, contextType: BreezeContextType.Main)

或通过谓词查找

let cars = Car.findAll(predicate: myPredicate, sortedBy: "anotherAttribute", ascending: false, contextType: BreezeContextType.Main)

计数

如果您只需要计数查询的对象,请使用 countAll 函数

let carCount = Car.countAll(predicate: myPredicate, sortedBy: "anotherAttribute", ascending: false, contextType: BreezeContextType.Main)

许可证

Breeze 在 MIT 许可证下可用。请参阅文件 LICENSE。