【发布时间】:2018-11-06 12:28:26
【问题描述】:
提前感谢您的帮助, 我有两个 API 调用,都是并发的,任何调用都可能首先成功(我不想按顺序调用),在两个调用成功后,我必须停止我的活动指示器并重新加载我的 tableView, 这是我的代码,但我不知道这是否正确,以及如何重新加载我的 tableView 并停止我的活动指示器。
func downloadDetails(){
let operationQueue: OperationQueue = OperationQueue()
let operation1 = BlockOperation() {
WebServiceManager.getAData(format:A, withCompletion: {(data: Any? , error: Error?) -> Void in
if let success = data {
DispatchQueue.main.async {
(success code)
}
}
})
let operation2 = BlockOperation() {
webServiceManager.getBData(format: B, withCompletion: {(data: Any? , error: Error?) -> Void in
if let success = data {
DispatchQueue.main.async {
(success code)
}
}
})
}
operationQueue.addOperation(operation2)
}
operationQueue.addOperation(operation1)
}
downloadDetails() "calling function"
【问题讨论】:
标签: ios swift4 nsoperationqueue nsoperation swift4.1