Downloading Data in SwiftUI with URLSession and async/await

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.

Using Guards in Swift to Avoid the Pyramid of Doom

Conditionals are a fundamental part of programming in Swift.

The first conditional statement you learn is the if statement. It’s not the only one, though, nor is it the most used.

Another example is a guard statement. Guard statements are often much more common than if statements.

A Comprehensive Guide to URLs in Swift and SwiftUI

URLs are omnipresent in today’s world, and iOS apps are no exception.

The URLs you use in Swift can identify different resources. The most common examples are web content, local files, and REST API endpoints.

The way you handle a URL in Swift depends on two things. The resource it identifies and how you manage the resource in the architecture of your app.

Learn Swift Programming: The essential step to creating iOS apps

The first step to making iOS apps is learning Swift.

But learning a new programming language can be daunting if you approach it for the first time.

Nonetheless, if you follow the right path, learning Swift can be fun and rewarding. Many developers worldwide use Swift because they like to build well-crafted programs.

In this article, I show you the right path to learning Swift.

I won’t only cover the how, but I will also explain why each piece is essential to build the whole puzzle.

The Best and Fastest Ways to Install Xcode on your Mac

The Best and Fastest Ways to Install Xcode on your Mac

The easiest way to install Xcode is using the Mac App Store.

But that’s not necessarily the best way.

While you can install Xcode with a simple click, using the Mac App Store is very slow, and the download might hang indefinitely or return cryptic errors.

The best alternative way to install Xcode is to download it from Apple’s website. If you are proficient enough, using the command line is the fastest.

In this article, we will look at all of the alternative ways to install Xcode, how to speed up the process, and how to resolve disk space problems. We’ll also look at the Windows alternative to Xcode.

Effortless Concurrency in Swift with Async/Await

Most modern iOS apps need to run code asynchronously. 

Asynchronous code can be suspended and resumed later, allowing your app to keep its UI responsive while working on long tasks, like performing network requests to a REST API. 

You often run asynchronous code in parallel to make the best use of resources like the cores on your device’s CPU or internet bandwidth.

In this article, we will see how to run asynchronous functions in Swift and iOS apps using async/await.

Powerful Advanced Swift Techniques for Complex Apps

Top image

Any iOS developer, at some point, feels the need to make the step from basic to advanced concepts.

You can get a lot of mileage from the fundamentals of Swift and iOS development.

But working on complex projects demands a new set of tools if you want your code to be reusable and remain at the same time maintainable and testable.

If you are looking to expand your Swift knowledge into more advanced topics and understand why you would need such concepts, this article is for you.