Skip to content

Instantly share code, notes, and snippets.

@dqhieu
Last active March 12, 2017 16:31
Show Gist options
  • Save dqhieu/e1511af4bc58945d8dc35aa6a3ef161f to your computer and use it in GitHub Desktop.
Save dqhieu/e1511af4bc58945d8dc35aa6a3ef161f to your computer and use it in GitHub Desktop.
Delay action in Swift
// 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