swift信号量

作者: 小羊爱学习 | 来源:发表于2023-04-03 11:39 被阅读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()
            }
    

    相关文章

      网友评论

        本文标题:swift信号量

        本文链接:https://www.haomeiwen.com/subject/dabdddtx.html