Learn more about Actors

Protecting mutable state with Mutex in Swift

Updated on: May 8, 2025

Once you start using Swift Concurrency, actors will essentially become your standard choice for protecting mutable state. However, introducing actors also tends to introduce more concurrency than you intended which can lead to more complex code, and a much harder time transitioning to Swift 6 in the long run. When you interact with state that’s […]

Read post

Dispatching to the Main thread with MainActor in Swift

Published on: April 23, 2024

Swift 5.5 introduced loads of new concurrency related features. One of these features is the MainActor annotation that we can apply to classes, functions, and properties. In this post you’ll learn several techniques that you can use to dispatch your code to the main thread from within Swift Concurrency’s tasks or by applying the main […]

Read post

Actor reentrancy in Swift explained

Updated on: April 23, 2024

When you start learning about actors in Swift, you’ll find that explanations will always contain something along the lines of “Actors protect shared mutable state by making sure the actor only does one thing at a time”. As a single sentence summary of actors, this is great but it misses an important nuance. While it’s […]

Read post

Using async await in Swift to build an image loader

Updated on: July 4, 2025

Async/await will be the defacto way of doing asynchronous programming on iOS 15 and above. I’ve already written quite a bit about the new Swift Concurrency features, and there’s still plenty to write about. In this post, I’m going to take a look at building an asynchronous image loader that has support for caching. SwiftUI […]

Read post

Building a token refresh flow using async await in Swift

Updated on: July 4, 2025

One of my favorite concurrency problems to solve is building concurrency-proof token refresh flows. Refreshing authentication tokens is something that a lot of us deal with regularly, and doing it correctly can be a pretty challenging task. Especially when you want to make sure you only issue a single token refresh request even if multiple […]

Read post

Preventing data races with Swift’s Actors

Updated on: January 24, 2025

We all know that async / await was one of this year’s big announcements WWDC. It completely changes the way we interact with concurrent code. Instead of using completion handlers, we can await results in a non-blocking way. More importantly, with the new Swift Concurrency features, our Swift code is much safer and consistent than […]

Read post

WWDC Notes: Protect mutable state with Swift actors

Updated on: September 13, 2022

Data races make concurrency hard. They occur when two threads access the same data and at least one of them is a write. It’s trivial to write a data race, but it’s really hard to debug. Data races aren’t always clear, aren’t always reproducible, and might not always manifest in the same way. Shared mutable […]

Read post

Expand your learning with my books

Practical Core Data header image

Learn everything you need to know about Core Data and how you can use it in your projects with Practical Core Data. It contains:

  • Twelve chapters worth of content.
  • Sample projects for both SwiftUI and UIKit.
  • Free updates for future iOS versions.

The book is available as a digital download for just $39.99!

Learn more