我是异步和同步机制的新手。在我的代码中,我必须在另一行完成后才执行另一行代码。它看起来像这样:
func something(){
let workerQueue = DispatchQueue.global(qos: .userInitiated)
workerQueue.async{
let info = getInfoFromTheWeb()//I need the info value in order to perform the next line
saveToDB(info: info)
DispatchQueue.main.async {
//update a label text in the ui after getting and saving that info
}
}
}
Run Code Online (Sandbox Code Playgroud)
请你的专业意见..