Created
November 6, 2015 18:55
-
-
Save mmcbrear/d0e929b5fbb6173ef620 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// GCD+Utils.swift | |
// - | |
// | |
// | |
// Use: | |
// ASyncMain() { | |
// your code executed on main thread | |
// } | |
// | |
// Use: | |
// ASyncAfter(0.5) { | |
// your code executed main thread after 0.5s | |
// } | |
extension NSObject { | |
func ASyncMain(block: dispatch_block_t) { | |
dispatch_async(dispatch_get_main_queue(), block) | |
} | |
func ASyncAfter(after: Double, block: dispatch_block_t) { | |
dispatch_after( | |
dispatch_time(DISPATCH_TIME_NOW, Int64(after * Double(NSEC_PER_SEC))), | |
dispatch_get_main_queue(), | |
block) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment