Async and Isolation
async and await, structured tasks, async sequences, actors and Sendable checking: the model Swift 6 enforces at compile time. Interviewers ask about isolation and data races.
on this pageshowhide
explore
- Suspension Points and Continuations5 questions
- Tasks, Groups and Cancellation5 questions
- Asynchronous Sequences and Streams5 questions
- Actors and Reentrancy6 questions
- Sendable and Data-Race Safety6 questions
- Grand Central Dispatch6 questions
questions
page 2 of 2As a lead on a Swift app, how do you decide which shared state becomes an actor, which stays on the main actor, and which sits behind a `Mutex`?
basics
~20 sKeep state the UI reads on the main actor; make an actor for shared state whose operations are coarse, asynchronous and used from background work; use a Mutex for small synchronous critical sections that any context must call without await.
As iOS lead on a GCD-heavy app adopting Swift 6 language mode, which Dispatch and OperationQueue code would you move to async/await first, and which would you keep?
basics
~20 sMove first the GCD code that blocks or guards shared state: semaphore and group waits, barrier-protected caches and main-queue hops for UI state. Keep queues an API requires, dispatch sources and working OperationQueue graphs, and wrap them at the boundary.
As a lead moving a large Swift codebase to Swift 6 language mode, in what order would you migrate modules, and which shortcuts would you restrict?
basics
~20 sMigrate module by module, dependencies first: preview Swift 6 errors as warnings with -strict-concurrency=complete in Swift 5 mode, fix them, then switch that module to Swift 6 mode. Use @preconcurrency import as temporary scaffolding and gate @unchecked Sendable and nonisolated(unsafe) behind review.
showing 31–33 of 33