0
0
iOS Swiftmobile~20 mins

Pull-to-refresh (refreshable) in iOS Swift - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pull-to-Refresh Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What happens when you pull down on a SwiftUI List with .refreshable modifier?
Consider a SwiftUI List with the .refreshable modifier added. What is the expected behavior when the user pulls down on the list?
iOS Swift
List(items, id: \.self) { item in
  Text(item)
}
.refreshable {
  await fetchData()
}
AThe list crashes because .refreshable is not supported on List.
BThe list immediately reloads without calling fetchData(), no indicator is shown.
CNothing happens because .refreshable requires a button press to activate.
DThe list triggers the fetchData() async function and shows a spinning indicator until it completes.
Attempts:
2 left
💡 Hint
Think about what .refreshable is designed to do in SwiftUI.
lifecycle
intermediate
1:30remaining
When does the refresh closure run in a SwiftUI .refreshable modifier?
In SwiftUI, the .refreshable modifier takes an async closure. When exactly is this closure executed?
iOS Swift
List { ... }
.refreshable {
  await loadData()
}
AOnly when the user pulls down far enough to trigger the refresh control.
BImmediately when the view appears on screen.
CEvery time the list scrolls up or down.
DWhen the user taps on any list item.
Attempts:
2 left
💡 Hint
Think about user interaction with pull-to-refresh.
🔧 Debug
advanced
2:30remaining
Why does the spinner never stop after pull-to-refresh in this SwiftUI code?
Given this SwiftUI code snippet, the spinner shows but never disappears after pulling to refresh. What is the cause?
iOS Swift
List(items, id: \.self) { item in
  Text(item)
}
.refreshable {
  fetchData()
}
AThe List must be inside a ScrollView for refreshable to work.
BThe .refreshable modifier requires a synchronous closure.
CfetchData() is not awaited, so the refresh never completes.
DThe items array is empty, so the spinner stays indefinitely.
Attempts:
2 left
💡 Hint
Check if the async function is awaited properly.
🧠 Conceptual
advanced
1:00remaining
What is the minimum iOS version that supports SwiftUI's .refreshable modifier?
You want to use the .refreshable modifier in your SwiftUI app. Which iOS version must your app target at minimum?
AiOS 15.0
BiOS 14.0
CiOS 13.0
DiOS 16.0
Attempts:
2 left
💡 Hint
Check Apple documentation for .refreshable availability.
navigation
expert
3:00remaining
How to programmatically trigger pull-to-refresh in SwiftUI List with .refreshable?
You want to start the refresh spinner and call the refresh closure programmatically without user pulling down. Which approach works best?
ACall the .refreshable closure directly from code using a function reference.
BUse UIKit's UIRefreshControl and integrate it with SwiftUI List via UIViewRepresentable.
CUse a @State boolean to conditionally show a ProgressView above the List and call fetchData() manually.
DSet the List's scroll position to top programmatically to simulate pull-to-refresh.
Attempts:
2 left
💡 Hint
SwiftUI does not provide a direct API to trigger .refreshable programmatically.