Bird
0
0

What is wrong with this SwiftUI pull-to-refresh code?

medium📝 Debug Q14 of 15
iOS Swift - Lists and Data Display
What is wrong with this SwiftUI pull-to-refresh code?
List(data) { item in
  Text(item.name)
}
.refreshable {
  fetchData()
}
AList requires an explicit id parameter
Brefreshable cannot be used on List
CfetchData() is missing await and async keywords
DText cannot display item.name
Step-by-Step Solution
Solution:
  1. Step 1: Check the refreshable closure requirements

    The closure must be async and await the async function inside.
  2. Step 2: Identify missing async/await usage

    fetchData() is called without await and the closure is not marked async, causing a compile error.
  3. Final Answer:

    fetchData() is missing await and async keywords -> Option C
  4. Quick Check:

    refreshable closure must be async with await calls [OK]
Quick Trick: Use async closure and await inside refreshable [OK]
Common Mistakes:
  • Forgetting to mark closure async
  • Calling async functions without await
  • Thinking refreshable can't be used on List

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes