Bird
0
0

What does the await keyword do in Swift's async/await syntax?

easy📝 Conceptual Q1 of 15
iOS Swift - Concurrency
What does the await keyword do in Swift's async/await syntax?
AIt makes the function run on a background thread automatically.
BIt pauses the current function until the asynchronous task completes.
CIt converts synchronous code into asynchronous code.
DIt cancels the asynchronous task immediately.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of await

    The await keyword tells Swift to pause the current async function until the awaited task finishes.
  2. Step 2: Differentiate from other options

    It does not automatically switch threads, convert code, or cancel tasks; it only waits for completion.
  3. Final Answer:

    It pauses the current function until the asynchronous task completes. -> Option B
  4. Quick Check:

    await pauses current function [OK]
Quick Trick: Remember: await pauses, it does not cancel or switch threads [OK]
Common Mistakes:
  • Thinking await runs code on a background thread
  • Confusing await with task cancellation
  • Assuming await converts sync code automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes