Created
May 16, 2016 16:38
-
-
Save jonathan-beebe/e3e7cf0c43b7ca2c3917d462329c0545 to your computer and use it in GitHub Desktop.
Helpers to make dispach_* code in Swift a bit more concise.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func async(callback:(Void -> Void)) { | |
dispatch_async(dispatch_get_main_queue(), { () -> Void in | |
callback() | |
}) | |
} | |
func after(delay:Double, closure:Void->Void) { | |
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