Swift 6 · SwiftUI basics
Load data when a view appears
The task modifier runs async work and cancels it when the view goes away.
.task {
items = (try? await loadItems()) ?? []
}
Official Swift 6 documentation
Swift 6 · SwiftUI basics
The task modifier runs async work and cancels it when the view goes away.
.task {
items = (try? await loadItems()) ?? []
}
Official Swift 6 documentation
Was this page helpful?