This question already has an answer here:
Hi i am trying to execute this line of code in playground but getting any output of response.My Code is as follow:
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)")
})
I had to write
at the top of file
This solved.