REST API Calls in Swift: iOS Networking Architecture [in SwiftUI]

You can make a REST API call in Swift in just three lines of code thanks to URLSession and async/await.

However, implementing a networking layer in a full-fledged app presents several architectural pitfalls.

In this article we will see how REST works, how to perform API calls in a SwiftUI app, and the best way to architect the networking layer of an iOS app.

Async Await in Swift: Concurrency Explained [With Examples]

Most modern iOS apps need to run code asynchronously. Async functions can be suspended and resumed later, allowing your app to keep its UI responsive while working on long tasks, like making REST API calls. In this article, we will see how to run asynchronous functions in Swift and iOS apps using async/await. Table of … Read more

Switch Statements in Swift: Selecting Among Multiple Options

Switch statements are a powerful tool for controlling the flow of your program based on the value of a variable or expression. Although they resemble if-else statements with multiple clauses, switch statements offer several advantages.

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.

Organizing Data by Key in Swift Dictionaries

In Swift programs, it is often necessary to organize large amounts of data within collections.

Arrays are the most commonly used collection in programming. However, it is not always necessary to order data sequentially.

Frequently, data retrieval requires using a specific key, such as when searching for the definition of a word in a dictionary.

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.