Actors & Sendable
An actor is a class the compiler guards
You met actors in lesson 1's fix for WalkStats. The full picture: an actor looks and feels like a class β properties, methods, init β but the compiler enforces that only one method call is running at a time, from any thread. Call a second method while the first is mid-flight and it simply waits its turn. That's serial access, guaranteed at compile time, with no lock you have to remember to take.
@MainActor β the annotation on every view model you've written β is a specific actor: the one tied to the main thread. Marking a class @MainActor doesn't create a new actor, it says "this type's methods only ever run on the existing main-thread actor", which is exactly why it's safe to touch @Published-style properties from it and have SwiftUI redraw immediately.