Skip to content

Instantly share code, notes, and snippets.

@danielgalasko
Last active June 14, 2017 07:06
Show Gist options
  • Save danielgalasko/bdd363a8c3b530d8bca8 to your computer and use it in GitHub Desktop.
Save danielgalasko/bdd363a8c3b530d8bca8 to your computer and use it in GitHub Desktop.
dispatch_after in Swift - A top level function for delaying code execution
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(), closure)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment