swift信号量
2023-04-03 本文已影响0人
小羊爱学习
let queue = DispatchQueue(label: "queue")
queue.async {
let semaphore = DispatchSemaphore.init(value: 0)
let target = NetworkAPI.syncVehicleCert(password: self.passwordView.value, seid: self.boxNoView.value, step: STEP, typeId: TYPE_ID, vehicleData: jsonData)
NetworkManager<String>().request(target) { result in
if result.code == "10000" {
semaphore.signal()
} else {
semaphore.signal()
SVProgressHUD.showError(withStatus: result.info)
return
}
}
semaphore.wait()
let target2 = NetworkAPI.boxBind(password: self.passwordView.value, vin: "")
NetworkManager<String>().request(target2) { result in
if result.code == "10000" {
semaphore.signal()
SVProgressHUD.showSuccess(withStatus: "添加成功")
self.navigationController?.popViewController(animated: true)
} else {
SVProgressHUD.showError(withStatus: result.info)
return
}
}
semaphore.wait()
}