Skip to content

Instantly share code, notes, and snippets.

@vknabel
Created July 12, 2015 13:22
Show Gist options
  • Save vknabel/d40574111bb1a279f205 to your computer and use it in GitHub Desktop.
Save vknabel/d40574111bb1a279f205 to your computer and use it in GitHub Desktop.
import Foundation
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(), closure)
}
func async(closure:()->()) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), closure)
}
func main(closure:()->()) {
dispatch_async(dispatch_get_main_queue(), closure)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment