Create Object Class:
class Dog: Object {
dynamic var name = ""
dynamic var age = 0
}
Assign Object's Values:
let dog = Dog()
dog.name = "Rex"
dog.age = 1
Save Object:
let realm = try! Realm()
try! realm.write {
realm.add(dog)
}
Reading Objects:
let realm = try! Realm()
let pups = realm.objects(Dog.self)
Filtering Objects:
let realm = try! Realm()
let filteredPups = realm.objects(Dog.self).filter("age < 2")
Counting Objects:
let realm = try! Realm()
let pupsCount = realm.objects(Dog.self).count