Async/await in Swift
summary
Async/await is available in Swift 5.5+ (Xcode 13/14) and converts nested completion-handler code into straightline calls, demonstrated by a URLSession article fetch, JSON decoding and image extraction that become simple await/try returns. Xcode offers a refactor to convert callbacks to async, and legacy callbacks are wrapped with checkedContinuation to bridge APIs. SwiftUI uses the task view modifier and Task contexts to call async methods and Firebase functions map to async automatically via Swift Evolution 0297.
AI-written summary · about
chapters (7)
- 0:00Intro
- 1:14Asynchronous code is everywhere
- 4:10Let's add some error handling...
- 8:22Let's convert a callback-based function!
- 11:47Sometimes, it's more complicated, though
- 15:23await: only from within async context
- 19:53Firebase and async/await
related talks
31mFuture of Swift: A Sneak Peek at async / await
35mSwiftUI, Async/Await, AsyncAlgorithms: How does it all fit?
42mAsync Await and More in Swift
35mThe Multi-Threaded Asynchronous Parallel World of Swift
44mSwift 6, Async/Await, SwiftUI went into a Bar...
34mModern SwiftUI Callbacks using AsyncStream
29mWilling Suspension of Disbelief
47mManaging Combine, your existing code, and async/await
