Bird
0
0

Why does Swift's structured concurrency require that all child tasks complete or be cancelled before the parent task finishes?

hard📝 Conceptual Q10 of 15
iOS Swift - Concurrency
Why does Swift's structured concurrency require that all child tasks complete or be cancelled before the parent task finishes?
ATo allow child tasks to run indefinitely in the background.
BTo improve UI responsiveness by delaying task completion.
CTo disable error propagation from child to parent tasks.
DTo ensure predictable resource management and avoid orphaned tasks.
Step-by-Step Solution
Solution:
  1. Step 1: Understand structured concurrency design

    It enforces task hierarchy so resources are cleaned up and no tasks run without control.
  2. Step 2: Identify reason for waiting or cancelling child tasks

    This prevents orphaned tasks that waste resources or cause unpredictable behavior.
  3. Final Answer:

    To ensure predictable resource management and avoid orphaned tasks. -> Option D
  4. Quick Check:

    Structured concurrency = controlled task lifecycle [OK]
Quick Trick: Child tasks must finish to keep app stable and predictable [OK]
Common Mistakes:
  • Thinking child tasks run forever
  • Believing error propagation is disabled
  • Assuming UI responsiveness depends on this

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes