Home / @MainActor interview question Swift
Swift concurrency
@MainActor interview question
@MainActor is how Swift keeps UI work on the main thread in the concurrency model. Interviews test whether you know its limits, not just its purpose.
What @MainActor does
Marking a type, function, or property @MainActor guarantees its code runs on the main actor, which is bound to the main thread, so UI updates are safe. Calls from off the main actor become async and hop onto it. This replaces manual DispatchQueue.main.async with a compiler-checked guarantee.
What it does not do, and overuse
@MainActor does not make your whole app thread safe, and it does not mean work is fast; heavy computation on the main actor still blocks the UI. A common mistake is annotating everything @MainActor, which serializes work that should run off the main thread. Keep expensive work off the main actor and only hop back to update UI.
Go deeper than a summary
Share Your Screen works topics like this through in full: 75 solved Swift problems with tests, 9 real case studies, and 7 annotated mock interviews, so you rehearse the live round instead of just reading about it.
Frequently asked
What does @MainActor guarantee?
That the annotated code runs on the main actor, and therefore the main thread, making UI updates safe without manual dispatching.
Can @MainActor hurt performance?
Yes, if you put heavy computation on it. It serializes work on the main thread, so expensive tasks there block the UI. Do heavy work off-main and hop back only to update UI.