DevPrep

All topics › Swift Concurrency (async/await, actors)

What is async/await and what problem does it solve?

Middle PRO

The essence

async/await is the language-level asynchrony model (Swift 5.5, iOS 15). A function marked async can suspend at an await without blocking the thread: the thread returns to the pool and does other work, and when the result is ready the function resumes from the same spot. The code reads linearly, errors flow through plain throws/try, and the compiler checks that you did not forget a callback or call it twice.

The problems it solves: the "pyramid" of nested completion handlers, lost or double callback calls, manual error forwarding, no way to statically check thread safety.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store