Reputation: 1074
just wondering, how do I convert List to Result?
Cause I'm doing filtering of region and areas, and when user selected region then area should show only those area in the region. And when I'm asigning my areas to a variable defined as var areas: Results<Area>!
, I got the compile error
Cannot assign value of type 'List' to type 'Results!'
my code is as below
if let regionString = self.selectedRegionString {
let region = self.realm.objects(Region).filter("name = '\(regionString)'").first
self.areas = region!.areas //this line is the problem
} else {
self.areas = self.realm.objects(Area)
}
Upvotes: 3
Views: 4314
Reputation: 7010
I think you should define your self.areas
like
var areas: List<Area>
It should have the same model class
Results
is used for Realm's queries returned value.
Upvotes: 4