gpt4 book ai didi

swift - swift 3 Playground 中的回调

转载 作者:可可西里 更新时间:2023-11-01 00:36:02 25 4
gpt4 key购买 nike

<分区>

您好,我正在尝试在 playground 中执行这行代码,但得到任何响应输出。我的代码如下:

func testCallbackEmpty( callback: @escaping  () -> Void) {

DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
callback()
}
}

testCallbackEmpty(callback: { () -> Void in
print("Hey called here")
})


enum Result {
case OK, FAILED
}


func mainCallback(callback: @escaping (Result) -> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
callback(Result.OK)
}

}

mainCallback(callback: { result in
print("Hurray \(result)")
})

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com