Bird
0
0

What will happen if you omit the try keyword when calling URLSession.shared.data(from: url) with async/await?

medium📝 Predict Output Q5 of 15
iOS Swift - Networking
What will happen if you omit the try keyword when calling URLSession.shared.data(from: url) with async/await?
AThe code will compile but crash at runtime
BThe request will run synchronously
CThe request will succeed without error handling
DThe code will not compile due to missing try
Step-by-Step Solution
Solution:
  1. Step 1: Understand try keyword role

    try is required to call throwing functions; omitting it causes compile error.
  2. Step 2: Check consequences

    Without try, the compiler reports an error; code won't compile.
  3. Final Answer:

    The code will not compile due to missing try -> Option D
  4. Quick Check:

    Missing try causes compile error = B [OK]
Quick Trick: Always use try with throwing async calls [OK]
Common Mistakes:
  • Thinking code compiles but crashes
  • Assuming try is optional
  • Confusing try with await

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes