【发布时间】:2021-04-29 19:36:25
【问题描述】:
想知道有没有什么办法可以延迟函数的return语句……举个例子:
func returnlate() -> String {
var thisStringshouldbereturned = "Wrong"
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
// Here should be the String changed
thisStringshouldbereturned = "right"
}
// The Return-Statement returns the First Value ("Wrong")
// Is there a way to delay the return Statement?
// Because you can't use 'DispatchQueue.main.asyncAfter(deadline: .now() + 1)'
return thisStringshouldbereturned
}
谢谢,祝你有美好的一天,保持健康。
展位
【问题讨论】:
标签: swift