Daily iOS
Concurrency

MainActor isolation

In Swift Concurrency, what's the difference between putting @MainActor on a whole view model class and putting it on specific methods only?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

On the type, every stored property and method is isolated to the main actor, so other contexts have to await; on a method only, just that method runs on main and the rest of the state isn't protected. nonisolated takes immutable data and pure computation out of isolation.

Share a question