Created
June 13, 2014 15:06
-
-
Save kmikael/faf11ed5d1a3b27c3c6f to your computer and use it in GitHub Desktop.
Update `dispatch_async` to take a default `queue`
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 Dispatch | |
func dispatch_async(queue: dispatch_queue_t = dispatch_get_main_queue(), block: dispatch_block_t) { | |
Dispatch.dispatch_async(queue, block) | |
} | |
dispatch_async { | |
// Update the UI | |
} | |
// Alternatively, a less "hacky" solution | |
func async_main(block: dispatch_block_t) { | |
dispatch_async(dispatch_get_main_queue(), block) | |
} | |
async_main { | |
// Update the UI | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment