Many modern iOS apps are connected to the internet.
When you need to download or upload data, URLSession
is the solution.
Together with other types, URLSession
not only transfers data over a network but also groups transfers together.
This allows you to:
- Optimize data transfers.
- Handle authentication, cookies, and caching.
- Pause, resume, or cancel network transfers.
- Download data in the background when your app is suspended.
Due to the complexity of network transfers, using URLSession
is not straightforward and presents a few architectural challenges, especially in SwiftUI apps.
We will explore all of the above in this article.
Matteo has been developing apps for iOS since 2008. He has been teaching iOS development best practices to hundreds of students since 2015 and he is the developer of Vulcan, a macOS app to generate SwiftUI code. Before that he was a freelance iOS developer for small and big clients, including TomTom, Squla, Siilo, and Layar. Matteo got a master’s degree in computer science and computational logic at the University of Turin. In his spare time he dances and teaches tango.