We can use extensions to make life easier :
extension Realm {
func list(_ type: T.Type) -> List {
let objects = self.objects(type)
let list = objects.reduce(List()) { list, element -> List in
list.append(element)
return list
}
return list
}
}
Usage:
let objects = realm.list(YourObject.self)