Concurrency for Swift and SwiftUIs
Concurrency in Swift is the system for running work without blocking the interface, built on async and await, tasks, task groups and actors. Structured concurrency ties child tasks to a parent scope so they are cancelled and awaited together, and URLSession with Codable is the usual route to fetch and decode network data.
Stage: Data and Concurrency · Part of the Swift and SwiftUI roadmap · Last reviewed 19 November 2026
What to learn in Concurrency
- Write an async function and call it with await inside a Task
- Run independent requests in parallel with async let or a task group
- Protect shared mutable state using an actor
- Update UI safely by isolating code to the MainActor
- Fetch JSON with URLSession and decode it with Codable
- Handle cancellation and errors in asynchronous code
Concurrency interview questions
What problem do Swift actors solve?
Actors protect mutable state from data races. Only one task at a time can run code isolated to an actor, and outside callers must await access, so concurrent code cannot read and write the same properties simultaneously.
Why must UI updates happen on the MainActor?
UIKit and SwiftUI expect view state to change on the main thread. Marking code or types with @MainActor makes the compiler enforce that, so background work must hop to the main actor before touching anything the interface displays.
Where Concurrency fits in the Swift and SwiftUI roadmap
Concurrency belongs to the Data and Concurrency stage (intermediate level), which takes about 21 hours. Real app behaviour.
Other units in this stage
Back to the full Swift and SwiftUI roadmap