---
title: "#244: Grand Central Dispatch in Swift 3 🚦🐤"
url: https://littlebitesofcocoa.com/244-grand-central-dispatch-in-swift-3
author: Jake Marsh
date: 2016-07-11
published: 2016-07-11
topics: ["Concurrency","Foundation","Swift"]
description: "We've covered GCD a few times back in Bites #85 \u0026 #35. This year, GCD is getting a huge overhaul that brings it into the modern world of Swift."
---

# #244: Grand Central Dispatch in Swift 3 🚦🐤

By Jake Marsh, July 11, 2016. HTML: https://littlebitesofcocoa.com/244-grand-central-dispatch-in-swift-3

We've covered GCD a few times back in [Bites #85](https://littlebitesofcocoa.com/85) & [#35](https://littlebitesofcocoa.com/35). This year, _GCD_ is getting a <i>huge</i> 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 <i>richly typed</i> **Swift 3** API.

Here's a basic usage example:

``` swift
let queue = DispatchQueue(label: "com.jakemarsh.image-processing")

queue.async {
  let thumbnail = image.resize(to: thumbnailSize(for: image))

  DispatchQueue.main.async { 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:

``` swift
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 <i>much</i> safer and more intuitive to use in Swift. Neat!
