迅速

创建对象类:

class Dog: Object {
    dynamic var name = ""
    dynamic var age = 0
}   

分配对象的值:

let dog = Dog()
dog.name = "Rex"
dog.age = 1

保存对象:

let realm = try! Realm()
try! realm.write {
    realm.add(dog)
}

阅读对象:

let realm = try! Realm()
let pups = realm.objects(Dog.self)

过滤对象:

let realm = try! Realm()
let filteredPups = realm.objects(Dog.self).filter("age < 2")

计数对象:

let realm = try! Realm()
let pupsCount = realm.objects(Dog.self).count