Skip to content

Instantly share code, notes, and snippets.

@Zhukn1
Created June 28, 2015 16:36
Show Gist options
  • Save Zhukn1/99cad46b7539b73cd905 to your computer and use it in GitHub Desktop.
Save Zhukn1/99cad46b7539b73cd905 to your computer and use it in GitHub Desktop.
A handy and elegant implementation of the GCD's dispatch_after method.
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