For example:
<code> var body: some View {
ScrollViewReader(content: { proxy in
/* ... */
}).task {
do {
let url = URL(string: "https://example.com/data.json")!
let (data, _) = try await URLSession.shared.data(from: url)
/* ... */
} catch {
print(error)
}
}
}
</code>
<code> var body: some View {
ScrollViewReader(content: { proxy in
/* ... */
}).task {
do {
let url = URL(string: "https://example.com/data.json")!
let (data, _) = try await URLSession.shared.data(from: url)
/* ... */
} catch {
print(error)
}
}
}
</code>
var body: some View {
ScrollViewReader(content: { proxy in
/* ... */
}).task {
do {
let url = URL(string: "https://example.com/data.json")!
let (data, _) = try await URLSession.shared.data(from: url)
/* ... */
} catch {
print(error)
}
}
}
What does Task underneath? Is is for storing and restoring the state of the programm after the data-request has resolved?
New contributor
bob-at-ubuntu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.