Skip to content

Instantly share code, notes, and snippets.

@jingzhehu
Created October 26, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jingzhehu/95966b1b6455e378fce7efaa316ea649 to your computer and use it in GitHub Desktop.
Save jingzhehu/95966b1b6455e378fce7efaa316ea649 to your computer and use it in GitHub Desktop.
Delayed execution of closure
func delay(_ delay: Double, closure: @escaping () -> ()) {
let when = DispatchTime.now() + delay
DispatchQueue.main.asyncAfter(deadline: when, execute: closure)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment