我是新来的迅速,这周我对面即是已经让我掐我的头发,一个问题就来了!
会发生什么情况如下,在我的应用分成几个班离开我的代码更加“干净”,并在这一波我决定通过该项目来划分的一些功能成类,但到目前为止,一切顺利。
问题在于Swift如何处理执行队列,并将所有不在ViewController中的东西留给阻碍我的东西。
我会告诉你一些代码,以便更好地扩展我所说的内容。
我的视图控制器的按钮的功能:强制执行顺序 - Swift3/Xcode8 - 线程
@IBAction func btnLogin(_ sender: UIButton) {
//The line that the Swift "skips"
let dadosAlunoWS = FadbaWS.buscaAluno(matricula: MatriculaTbox.text!, senha: SenhaTbox.text!, token: "TOKEN")
//'dadosAlunoWS' aways empty because 'FadbaWS.buscaAluno'
//is only performed at the end of 'btnLogin'
if dadosAlunoWS.sucesso && dadosAlunoWS.usuarioEncontrado{
print(dadosAlunoWS.name)
}else{
//Error on request
}
}
我知道并行性和并发性和研究我能意识到这是斯威夫特原生的界面,这使得一切流体优先的概念,但我的问题是我的'FadbaWS.buscaAluno'函数从不执行,因此永远不会返回有效的值。
我该如何给予优先级,以便我的代码只在执行此功能后才能执行?
如何在Swift中处理DispatchQueue?
现在,感激!