how to convert RealmSwift List to Results?

做~自己de王妃 提交于 2019-12-05 02:47:06

Both List and Results (as well as LinkingObjects) can be converted into an AnyRealmCollection type. I think this is probably the best way to standardize all of Realm's array-type types:

var dataSource:AnyRealmCollection!
let aRealmObject = realm.objectForPrimaryKey(SomeObject.self, key: objectId) 
dataSource = AnyRealmCollection(aRealmObject.someList)

I have found A simple way to convert List to Results making use if the filter method, it always returns Results object. Just gave it a true predicate.

   dataSource = aRealmObject.someList.filter("TRUEPREDICATE") //this is a Results object.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!