Connect with us


How to get started with Swift Concurrency 🧵 (Beginner Tutorial)

Swift has built-in support for writing asynchronous and parallel code in a structured way. Asynchronous code can be suspended and resumed later, although only one piece of the program executes at a time. Suspending and resuming code in your program lets it continue to make progress on short-term operations like updating its UI while continuing to work on long-running operations like fetching data over the network or parsing files. Parallel code means multiple pieces of code run simultaneously — for example, a computer with a four-core processor can run four pieces of code at the same time, with each core carrying out one of the tasks. A program that uses parallel and asynchronous code carries out multiple operations at a time; it suspends operations that are waiting for an external system, and makes it easier to write this code in a memory-safe way.

The additional scheduling flexibility from parallel or asynchronous code also comes with a cost of increased complexity. Swift lets you express your intent in a way that enables some compile-time checking — for example, you can use actors to safely access mutable state. However, adding concurrency to slow or buggy code isn’t a guarantee that it will become fast or correct. In fact, adding concurrency might even make your code harder to debug. However, using Swift’s language-level support for concurrency in code that needs to be concurrent means Swift can help you catch problems at compile time.


  • 00:00:00 – Intro
  • 00:03:58 – Async await in Swift explained with code examples
  • 00:50:18 – Wrapping existing asynchronous code in async/await in Swift
  • 01:09:06 – Async let explained: call async functions in parallel
  • 01:19:53 – What role do Tasks play within Swift’s concurrency system?
  • 01:48:00 – Understanding Swift Task Groups With Example
  • 02:11:14 – Conclusion & Outro