This year marks 10 years since I started writing iOS apps. It also marks 10 years since I launched the first version of my blog, which was a thing hosted on Tumblr and on a completely different domain that I am not going to name here. A year after the Tumblr blog, I purchased andyibanez.com, got proper hosting, and started blogging on Wordpress with whatever little money I could make during my college days.
Every year, at WWDC, Apple gives us a lot of new things to play around with. For the big new things, they prepare session videos and labs so developers can experiment with the new technologies and hopefully integrate them in their apps by the time the new OSes are out.
The “big things” are one thing, but Apple introduces a bunch of new APIs every year. Many (oh boy, many) of them do not get any coverage at WWDC at all. Not in a session, and sometimes not even a small mention of them anywhere.
Modern Swift Concurrency Summary, Cheatsheet, and Thanks
Since WWDC21, we have talked, extensively, about all the new concurrency features introduced in Swift 5.5. We covered a lot of topics, so I decided to finish off this series writing a summary article were we cover the most important topics of each article. Links will be given to the relevant articles when necessary in case this summary is not enough.
Along the new concurrency APIs introduced in Swift at WWDC2021, we have AsyncSequence. AsyncSequence is a collection protocol that allow us to receive data in loops and even top higher order functions - such as filter, map and reduce - asynchronously, being able to await for new data as it becomes available.
We have recently talked about actors, what they are, and how to use them. If you remember, an actor controls access to its properties, so a member doesn’t get written from different processes at the same time, avoiding corrupted data.
When we are working with concurrency, the most common problem developers face are data races. Whether it is a task updating a value at the same time another task is reading it or two tasks writing a value so that it it has an invalid value, data races are probably the main pain point of concurrency. Data races are very easy create, and hard to debug. There are entire books dedicated to the problem of data races and established patterns to avoid them.
This article was originally written creating examples using Xcode 13 beta 1. The article, code samples, and provided sample project have been updated for Xcode 13 beta 3.
Understanding async tasks is a requirement to read this article. If you don’t understand async tasks, you can read the Introduction to Unstructured Concurrency in Swift article from this Article Series
This article was originally written creating examples using Xcode 13 beta 1. The article, code samples, and provided sample project have been updated for Xcode 13 beta 3.
This article was originally written creating examples using Xcode 13 beta 1. The article, code samples, and provided sample project have been updated for Xcode 13 beta 3.