I have the following Realm function to fetch all elements from the table in my Swift 3
app.
//Find all elements in the database
func findAll() -> [T] {
return getRealm().objects(T.self as! Object.Type)
}
How do I cast Result<Object>
from Realm
to [T]
in the return?
func findAll<T: Object>() -> [T] {
return getRealm().objects(T.self).map { $0 }
}