Network Requests and REST APIs in iOS with Swift (Protocol-Oriented Approach)

Network requests and REST APIs in iOS with Swift a Protocol Oriented Approach

Networking is a requirement for most modern iOS apps.

Networked apps usually interface with a remote web service that provides the data. And often, this web service is a REST API that returns data in JSON format.

Writing the networking layer of an iOS app, though, is not a simple task. To make asynchronous network calls, you need to use many features of Swift and UIKit, like the URLSession class and the Codable. Moreover, many parts of the app’s architecture need to interact, making the task more complicated than it seems.

Continue reading

Protocol-Oriented Programming: The Best Tool of Expert iOS Developers

Protocol-Oriented Programming: The Best Tool of Expert iOS DevelopersAfter the introduction of protocol extensions in Swift, Apple started pushing protocol-oriented programming.

Even if it was a new paradigm, it quickly got widespread adoption in Swift programming and iOS development. 

This is not a surprise. Protocol-oriented programming is a highly flexible paradigm with many benefits. One of my favorite applications is to create well-structured network requests.

Protocol-oriented programming solves many of the problems of object-oriented programming. Moreover, it works great with Swift’s value types, i.e., structures and enumerations.

Continue reading

Become an iOS Developer in 2019: The 3 Pillars to Jumpstart your Career

Become an iOS Developer in 2019 The 3 Pillars to Jumpstart your Career

More and more companies are relying on mobile apps, so iOS developers are in high demand.

Becoming an iOS developer takes some effort though, and the talent shortage keeps driving salaries higher and higher, even for entry-level positions.

So, it’s understandable that, more and more, people look into starting a career in iOS app development.

Money is not everything, of course. Many of us do it to create something we are proud of, that makes a difference in the lives of many people.

Whatever your reasons are, here is a detailed guide about what you need to learn to become an iOS developer.

Continue reading

For loops in Swift: a Detailed List of the Most Practical Uses

For loops in Swift a Detailed List of the Most Practical Uses

For loops are a fundamental construct of programming, and even more so of making iOS apps. If you want to become an iOS developer, they are a necessary tool you need to have in your toolbox.

But more important than simply understanding how they work, is to know how to use them for the different tasks you will meet in iOS development.

So, the aim of this article is not only to show you how Swift for loops work, but how to use them to solve the most common programming problems.

Continue reading

UITableview: The Essential Solution for Scrolling iOS Interfaces

UITableview: The Essential Solution for Scrolling iOS Interfaces

Table views are a fundamental component of almost any iOS app. But most developers don’t use them when they should or get their architecture wrong. 

Table views are more versatile than you might think.

For example, many developers make their life harder using a scroll view when a UITableView would be a better choice.

Finally, architecture is crucial for table views. The code of the table view data source often ends inside view controllers when it should go into a separate class.

Even though Apple introduced SwiftUI at WWDC 2019, you won’t be able to use it in your apps until a large portion of users gets on iOS 13.

Until then, you need to know the right approach to using table views with data sources and delegates.

Continue reading

Functional Programming in Swift: an Unusual yet Powerful Paradigm

Functional Programming in Swift an Unusual yet Powerful Paradigm

Since the introduction of Swift, the iOS community has been buzzing with the words functional programming.

That’s because many features of Swift were inspired by the ones you find in functional programming languages.

These features make some tasks easier. One example is easily configurable callbacks for network requests.

While Swift is not a functional language, we can draw many lessons from functional programming to write better Swift code in our iOS apps.

Continue reading

JSON Decoding in Swift with Codable: A Practical Guide

 JSON Decoding in Swift with Codable: A Practical Guide

Encoding and decoding data is a fundamental part of iOS apps.

That is especially true for the JSON data we get from REST APIs.

In the past, decoding JSON in iOS apps required a lot of boilerplate code and sometimes fancy techniques.

But thanks to the Codable protocols introduced in Swift 4, today we have a native and idiomatic way to encode and decode data.

The Codable protocols allow for simple JSON decoding that can sometimes take only a couple of lines of code. But it also allows for more sophisticated techniques when you have special needs.

We will explore all that in this article.

Continue reading