Bird
0
0

Given this SwiftUI code snippet, what happens when the user pulls down the list?

medium📝 ui behavior Q13 of 15
iOS Swift - Lists and Data Display
Given this SwiftUI code snippet, what happens when the user pulls down the list?
List(items, id: \.self) { item in
  Text(item)
}
.refreshable {
  await fetchNewItems()
}
AThe list reloads with new items after fetchNewItems completes
BThe list scrolls to the top without changing data
CNothing happens because refreshable requires a button
DThe app crashes due to missing completion handler
Step-by-Step Solution
Solution:
  1. Step 1: Understand the effect of .refreshable with async closure

    When user pulls down, fetchNewItems() runs asynchronously to update data.
  2. Step 2: Identify expected behavior after data fetch

    After fetchNewItems() completes, the list reloads showing updated items.
  3. Final Answer:

    The list reloads with new items after fetchNewItems completes -> Option A
  4. Quick Check:

    Pull-to-refresh triggers async update = list reload [OK]
Quick Trick: Pull triggers async fetch, then list updates [OK]
Common Mistakes:
  • Thinking refreshable needs a button
  • Assuming no data change happens
  • Believing app crashes without completion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes