In #183, I talked about Quality of Service (QoS) classes that were introduced in iOS 8. Async is a small library providing syntax sugar for GCD, supporting QoS.
Instead of doing this the pre-QoS classes way:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), {
print("This runs on the background queue")
dispatch_async(dispatch_get_main_queue(), {
print("This runs on the main queue, after the previous block")
})
})
You can do:
Async.background {
print("This runs on the background queue")
}.main {
print("This runs on the main queue, after the previous block")
}
There's a couple of examples in the README, including chaining blocks so you don't end up with many levels of code indentation. Check it out.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.