Skip to content

Instantly share code, notes, and snippets.

@tungpt247
Last active August 29, 2016 02:06
Show Gist options
  • Save tungpt247/924f5b781b13a3b373ff to your computer and use it in GitHub Desktop.
Save tungpt247/924f5b781b13a3b373ff to your computer and use it in GitHub Desktop.
execute a block code after a specified delay
func delay(delay: Double, closure: ()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(),
closure
)
}
delay(3.0) {
// TODO
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment