Last active
March 12, 2017 16:31
-
-
Save dqhieu/e1511af4bc58945d8dc35aa6a3ef161f to your computer and use it in GitHub Desktop.
Delay action in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 3 | |
func Delay(seconds: TimeInterval, _ completion: @escaping () -> Void) { | |
let when = DispatchTime.now() + seconds | |
DispatchQueue.main.asyncAfter(deadline: when) { | |
completion() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment