I already experienced this issue in the past, I fixed it.
But today I just download the new Xcode version 9.1 and my App is not building anymore, I got :
Ambiguous reference to member 'filter'
I don't know why, this is not the piece of code I was working on. The app is building/compiling fine since weeks.
When I check the Release Note on the Official Apple Website, I don't seem to find any reference to my issue.
So here is the piece of code that was working perfectly 2 hours ago :
var severeWeather: Results<SevereWeather>?
var vigiArray = Array<SevereWeather>()
var redCount: Int = 0
severeWeather = realm.objects(SevereWeather.self).filter(NSPredicate(format: "department != nil"))
.sorted(byKeyPath: "departmentNumber")
vigiArray = Array(severeWeather!)
redCount = vigiArray.filter { $0.dangerLevels.filter { $0.level.value == 4 }.count > 0 }.count
What is wrong with my code ?
RealmCollection also has a
filter
method, which is implemented differently. For some reason, Swift compiler doesn't know which one it should refer.What about this:
Instead of accessing each element in
dangerLevels
yourself, build Predicate and let realm do the job for you.Replace your nest filter with this and it should be compiling just fine.