Skip to content

Instantly share code, notes, and snippets.

@westerlund
Created June 23, 2015 14:08
Show Gist options
  • Save westerlund/394fc3c46fd88be4172f to your computer and use it in GitHub Desktop.
Save westerlund/394fc3c46fd88be4172f to your computer and use it in GitHub Desktop.
Dispatch after swift
func dispatch(#after: NSTimeInterval, queue: dispatch_queue_t = dispatch_get_main_queue(), #closure: dispatch_block_t) {
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(Double(after) * Double(NSEC_PER_SEC)))
dispatch_after(time, dispatch_get_main_queue(), closure)
}
func dispatch(#after: NSTimeInterval, closure: dispatch_block_t) {
dispatch(after: after, closure: closure)
}
dispatch(after: 0.5, { () -> Void in
// ...
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment