尝试使用主线程时 DispatchQueue 的歧义使用 [英] Ambiguous use of DispatchQueue on trying to use main thread
本文介绍了尝试使用主线程时 DispatchQueue 的歧义使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个奇怪的问题,我似乎找不到任何帮助.在 Swift 3 上,尝试在主线程上调用我尝试使用 DispatchQueue.main.async,但它无法编译.
This is a weird issue and I can't seem to find any help. On Swift 3, trying to make a call on the main thread I try to use DispatchQueue.main.async, but it doesn't compile.
任何想法都会有所帮助.
Any ideas would be helpful.
推荐答案
试试这个代码,这是 Swift 3.0 语法:
Try this code instead, this is the Swift 3.0 syntax:
DispatchQueue.main.async(execute: { () -> Void in
})
对于 Swift 4.x,您还可以使用:
DispatchQueue.main.async {
}
这篇关于尝试使用主线程时 DispatchQueue 的歧义使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文