Swift中主线程中执行UI任务记录
func methodUI() {
if Thread.current.isMainThread {
// ui action
} else {
DispatchQueue.main.async {
methodUI()
return
}
}
}func methodUI() {
if Thread.current.isMainThread {
// ui action
} else {
DispatchQueue.main.async {
methodUI()
return
}
}
}