extension Object{//Retrive model objects from realm database
@discardableResult
func retriveModel<T: Object>(type: T.Type) -> [T] {
do {
let realm = try Realm()
return realm.objects(T.self).toArray(ofType: T.self)
} catch let error as NSError {
fatalError(error.localizedDescription)
}
}}
@discardableResult
func retriveModel<T: Object>(type: T.Type) -> [T] {
do {
let realm = try Realm()
return realm.objects(T.self).toArray(ofType: T.self)
} catch let error as NSError {
fatalError(error.localizedDescription)
}
}}