RealmSwift: Convert Results to Swift Array Ask Question

RealmSwift: Convert Results to Swift Array Ask Question

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?

ベストアンサー1

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

let array = Array(results) // la fin

おすすめ記事