Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created June 6, 2016 09:55
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 fitomad/03c4110674c247fe5b5eef7758969dbd to your computer and use it in GitHub Desktop.
Save fitomad/03c4110674c247fe5b5eef7758969dbd to your computer and use it in GitHub Desktop.
/**
Execute closure after a delay
- Parameters:
-delay: Time to wait until execute closure
- closure: What is going to be executed
*/
public func delay(delay: Double, closure: () -> ())
{
let time_gcd: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)))
dispatch_after(time_gcd, dispatch_get_main_queue(), closure)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment