I\'ve gone through the iBook from Apple, and couldn\'t find any definition of it:
Can someone explain the structure of dispatch_after
?
d
Swift 3 & 4:
You can create a extension on DispatchQueue and add function delay which uses DispatchQueue asyncAfter function internally
extension DispatchQueue {
static func delay(_ delay: DispatchTimeInterval, closure: @escaping () -> ()) {
let timeInterval = DispatchTime.now() + delay
DispatchQueue.main.asyncAfter(deadline: timeInterval, execute: closure)
}
}
use:
DispatchQueue.delay(.seconds(1)) {
print("This is after delay")
}