RealmSwift: Convert Results to Swift Array

Sahil Kapoor picture Sahil Kapoor · Jun 28, 2015 · Viewed 72k times · Source

What I want to implement:

class func getSomeObject() -> [SomeObject]? {
    let objects = Realm().objects(SomeObject)

    return objects.count > 0 ? objects : nil
}

How can I return object as [SomeObject] instead if Results?

Answer

Mazyod picture Mazyod · Sep 8, 2015

Weird, the answer is very straight forward. Here is how I do it:

let array = Array(results) // la fin