We've covered GCD a few times back in Bites #85 & #35. This year, GCD is getting a huge overhaul that brings it into the modern world of Swift. Today we'll take a look at what's changed, let's dive in.

TLDR: Grand Central Dispatch now has a richly typed Swift 3 API.

Here's a basic usage example:

let queue = DispatchQueue ( label : "com.jakemarsh.image-processing" ) queue . as ync { let thumbnail = image . resize ( to : thumbnailSize ( for : image )) DispatchQueue . main . as ync { imageView . image = thumbnail } }

Here we create a new queue, and enqueue some image processing work on it. Then, we do the same thing, but back on the main queue, enqueueing the work of setting resized image on our imageView there.

That's just the beginning. Here's a few more examples of how to use the new "swifty" GCD:

Time & Delay:

let delayTime = DispatchTime . now () + . seconds ( 1 ) DispatchQueue . main . after ( when : delayTime ) { print ( "test" ) }

For seasoned GCD users, it may take some getting used to, but the new API is much safer and more intuitive to use in Swift. Neat!