我有一个这样的数组:
var arrayPoints:Variable<[Point]>?
稍后用户可以对列表进行排序:
func orderPointsByDistance(){
self.arrayPoints?.value.sort{ $0.stringDistance.compare($1.stringDistance) == .orderedAscending }
}
但是我收到了这个错误:
fatal error: Executing on backgound thread.
Please use MainScheduler.instance.schedule to schedule work on main thread.: file /Users/dasilvans/Desktop/GeoPlay/Pods/RxSwift/RxSwift/Rx.swift, line 23
在某种程度上我感知错误,但不知道如何解决它。 有什么建议吗?
答案 0 :(得分:0)
尝试这个我认为你在做那个时阻止rx
let stuff = Array(self.arrayPoints?.value)
stuff.sort{ $0.stringDistance.compare($1.stringDistance) == .orderedAscending }
self.arrayPoints?.value = stuff
或者是
的问题DispatchQueue.main.async {
}