I am using a Realm List/Results as my dataSource for a UITableView. At some point I assign a list to it. like:
var dataSource:List<SomeObject>! // Or >> Results<SomeObject>!
let aRealmObject = realm.objectForPrimaryKey(SomeObject.self, key: objectId)
dataSource = aRealmObject.someList // dataSource should be List
Then I have a filter on this list If the user changed the filter dates, I do like this:
dataSource = dataSource.filter("FILTER THE DATES",newDates) // dataSource should be Results
But the line above causes an error as the return type of filter is a Results object and aRealmObject.someList is a List.
What is the best way to deal with this situation?
- make dataSource as a
Listand convert theResultsobject toList? How?? - make dataSource as a
Resultsand convert theListtoResults? How?? - Or may be you have a better way of doing it, Please share it with me.
Thanks,
Both
ListandResults(as well asLinkingObjects) can be converted into anAnyRealmCollectiontype. I think this is probably the best way to standardize all of Realm's array-type types: