迅速

建立物件類:

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