作者:mobiledu2502901317 | 来源:互联网 | 2023-05-17 11:35
IamnewtoSwift,andtryingtoexamineafinishedproject.Butthereissomethingicouldntunder
I am new to Swift, and trying to examine a finished project. But there is something i couldn't understand.
我是Swift的新手,并试图检查一个完成的项目。但有一些我无法理解的东西。
After a network request is completed, the app show an alert under a condition.
网络请求完成后,应用程序会在条件下显示警报。
func makeNetworkRequest() {
//newtork result...
DispatchQueue.main.async {
self.showAlert(versionMessage: "Error")
}
}
func showAlert(versionMessage: String) {
let alert = UIAlertView(title: "", message: versionMessage, delegate: self)
alert.show()
}
However, it is done with a DispatchQueue
. Why would anyone need to use DispatchQueue
in this situation.
但是,它是使用DispatchQueue完成的。为什么在这种情况下任何人都需要使用DispatchQueue。
2 个解决方案