How can I use async/await with SwiftUI in Swift 5.5?
As per new informations in WWDC session Meet async/await in Swift
WWDC21, at 23m:28s this is now done using:
Task {
someState = await someAsyncFunction()
}
Screenshot from the session.
Note that there are more ways to instantiate a task. This is the most basic. You can use Task.detached
as well and both ways can get a priority argument.
Check both the Task docs and the session
Check Explore structured concurrency in Swift WWDC21 at around 23:05 (I recommend the whole session!) for more info.
Async/Await function without a return | Swift 5.5
This is what worked the best:
try await withUnsafeThrowingContinuation { (continuation: UnsafeContinuation<Void, Error>) in
Related Topics
Swift .Uppercasestring or .Lowercasestring Property Replacement
Perform a Segue Programmatically
How to Open Url in Safari and the Get Back to the App Under Uitests in Xcode 7
Swift Struct Doesn't Conform to Protocol Equatable
Case Insensitive Dictionary in Swift
Compiler Error: Invalid Library File - Corelocation
Cannot Assign to Property: 'Xxxx' Is a Get-Only Property
Mkmapview Not Clustering Annotation on Zooming Out Map in Swift
How to Sort Objects by Its Enum Value
How to Quit Swift Repl Without Using Ctrl-D
Create a Timer Publisher Using Swift Combine
How to Insert an Image Inline Uilabel in iOS 8 Using Swift
Swift Diffabledatasource Make Insert&Delete Instead of Reload
How to Add Initializers in Extensions to Existing Uikit Classes Such as Uicolor
How to Pass Protocol with Associated Type (Generic Protocol) as Parameter in Swift