Filters

Hide filters
Platform
Content Type
Difficulty

All Tutorials · 13 Results

Contained in: Modern Concurrency in Swift async/await
iOS & Swift

Chapter in Modern Concurrency in Swift

Getting Started With async/await

…into more detail about how the async/await syntax and the cooperative asynchronous execution work. Additionally, it introduces the usage of "async let" to design concurrent code and the "Task" type which encapsulates asynchronous execution in the modern concurrency model…
iOS & Swift

Chapter in Modern Concurrency in Swift

Intermediate async/await & CheckedContinuation

AsyncStream. You saw that wrapping existing APIs, like NotificationCenter, is very powerful, letting you reuse your tried-and-tested code in your modern async/await codebase. In this chapter, you’ll continue working in the same direction. You’ll look into more ways to reuse existing code to the fullest…
iOS & Swift

Chapter in Modern Concurrency in Swift

Why Modern Swift Concurrency?

…compared to older APIs. Later, in the practical part of the chapter, you’ll work on a real-life project by trying out the async/await syntax and adding some cool asynchronous error-handling. Understanding Asynchronous and Concurrent Code Most code runs the same way you see it written in your…
iOS & Swift
Modern Concurrency in Swift
…race conditions and unexplained crashes hidden in a massive nesting of callback closures. In Swift 5.5, Apple introduced a new concurrency model featuring the async/await syntax, to let you write asynchronous code that reads like synchronous code. But like any new feature, here be dragons! So how will you achieve…
iOS & Swift

Chapter in Modern Concurrency in Swift

Actors in a Distributed System

State of Distributed Actors in Swift Distributed actors were part of Swift’s larger set of proposals for modern concurrency. When Swift 5.5 introduced async/await initially, it did have partial experimental support for the distributed language feature, but not all implementations were complete. As the new concurrency features of async/await
iOS & Swift

Chapter in Modern Concurrency in Swift

Custom Asynchronous Sequences With AsyncStream

…guarantees that it mutates variables safely. Considering all of the above, in this chapter you’ll implement a simple countdown using the new async/await syntax yourself. Open BlabberModel.swift and scroll to countdown(to:). The timer button in the UI calls this method when the user taps it. Right…
iOS & Swift

Chapter in Modern Concurrency in Swift

Testing Asynchronous Code

…into logical pieces and making it more composable. But sometimes, depending on the situation, tests are just complex. However, you’ll see that using async/await makes even complex tests easier to design. Your say(_:) test was fairly simple because the method does a single thing and only sends a single…
iOS & Swift

Chapter in Modern Concurrency in Swift

AsyncSequence & Intermediate Task

Work with async sequences in more detail, proxying Combine to async/await code and managing async tasks…
iOS & Swift

Chapter in Modern Concurrency in Swift

Concurrent Code With TaskGroup

…made your way through a lot of new concepts so far. At this point, you’re hopefully comfortable with designing code with async/await, creating asynchronous sequences and running tasks in parallel with async let bindings. async let bindings are a powerful mechanism to help design your asynchronous flow, especially when…
iOS & Swift

Chapter in Modern Concurrency in Swift

Getting Started With Actors

…that you’ve created a fairly simple actor, it’s time to try a more complex design. You’ll mix actors, tasks and async/await to solve one of the eternal problems in programming: image caching. Throughout the rest of the chapter, you’ll build an actor that fetches the digital…
iOS & Swift

Chapter in Modern Concurrency in Swift

Global Actors

…safe silos out of code that needs to work with the same mutable state. Use a mix of actors and global actors, along with async/await and asynchronous sequences, to make your concurrent code safe. By completing the EmojiArt project, you’ve gained a solid understanding of the problems that actors…
iOS & Swift

Chapter in Modern Concurrency in Swift

What You Need

…need Xcode 14 or newer for the tasks in this book. If you’re using Xcode 13.2 and above, the new async/await syntax and the rest of the modern concurrency features will work starting with iOS 13 / macOS 10.15 SDK (or later). If you’re using an older version…
iOS & Swift

Chapter in Modern Concurrency in Swift

Conclusion

…well poised to move on to trying some of Swift’s new concurrency features in the real world. As you start incorporating async/await into your app and leveraging the powerful modern concurrency features Swift offers, like tasks and actors, your app will become safer and more predictable when it reads…