func getValue() -> Int {
var i = 0
let semaphore = DispatchSemaphore(value: 1)
// 模拟异步操作
UIView.animate(withDuration: 3.0) {
i = 100
semaphore.signal()
}
semaphore.wait()
return i
}
func getValue() -> Int {
var i = 0
let semaphore = DispatchSemaphore(value: 1)
// 模拟异步操作
UIView.animate(withDuration: 3.0) {
i = 100
semaphore.signal()
}
semaphore.wait()
return i
}