swift 5.3
命令发送发生漏包
第二个命令拿到第一个命令的返回值
所以想加一个异步等待。
怎么实现
func sendFirstCommand() async -> String {
return "First Command Result"
}
func sendSecondCommand(result: String) {
print("First command result: \(result)")
}
async func performCommands() {
let result = await sendFirstCommand()
sendSecondCommand(result: result)
}
Task {
await performCommands()
}