Task: try or no try

hejliang

Liang Wang

Posted on January 29, 2024

Task: try or no try

In the ContentView I have this modifier added to fetch data:
.task {
await viewModel.fetchData()
}

It works great! But if I accidentally added a try before await, Xcode will complain about Invalid conversion from throwing function of type '@Sendable () async throws -> ()' to non-throwing function type '@Sendable () async -> Void'

Don't try if it is NOT needed.

💖 💪 🙅 🚩
hejliang
Liang Wang

Posted on January 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related