Learn more about Swift

Error handling in Swift with do catch

Updated on: July 4, 2025

Handling errors in Swift is done using a mechanism where functions specify their ability to throw errors. In modern Swift versions (6.0 and up), functions can even specify the type of the error that the function might throw. When we call a function that can throw, we use special syntax to either ignore the error […]

Read post

How and when to use callAsFunction in Swift 5.2

Published on: February 17, 2020

A new Swift 5.2 feature is the ability to call instances of types as functions. Or, as the Swift Evolution proposal calls it “Callable values of user-defined nominal types”. The very short description of this feature is that it allows you to call instances of any type that has a callAsFunction method implemented as if […]

Read post

Using preconditions, assertions, and fatal errors in Swift

Updated on: January 19, 2024

As developers, we are often told that we should avoid crashing our apps at all costs. It’s why we are told that we shouldn’t force unwrap our optionals, that we should avoid unowned references and that we should never use try! in production code. In today’s article, I would like to offer you a counter […]

Read post

The some keyword in Swift explained

Updated on: September 25, 2025

If you’re using SwiftUI to build your apps, you will have noticed that your view’s body property is of type some View. The some keyword was introduced alongside SwiftUI and it’s part of a feature called opaque result types (SE-0244). In this post, we’ll take a look at what the some keyword is exactly, which […]

Read post

Generics in Swift explained

Updated on: August 21, 2024

Whenever we write code, we want our code to be well-designed. We want it to be flexible, elegant and safe. We want to make sure that Swift’s type system and the compiler catch as many of our mistakes as possible. It’s especially interesting how Swift’s type system can help us avoid obvious errors. For example, […]

Read post

Building flexible components with generics and protocols

Updated on: June 10, 2021

Recently I wanted to build a generic data source layer. This data source would be able to return pretty much anything from a local cache, or if the local cache doesn’t contain the requested object, it would fetch the object from a server and then cache the result locally before returning it to me. To […]

Read post

Uploading images and forms to a server using URLSession

Updated on: January 25, 2024

One of those tasks that always throws me off balance is building a form that allows users to upload a form with a picture attached to it. I know that it involves configuring my request to be multipart, that I need to attach the picture as data and there’s something involved with setting a content […]

Read post

What is Module Stability in Swift and why should you care?

Updated on: February 10, 2020

The Swift team has recently released Swift 5.1. This version of the Swift language contains many cool features like Function Builders that are used for SwiftUI and Property Wrappers that can be used to add extra functionality to properties. This release also contains a feature called Module Stability. But what is this feature? And what […]

Read post

Cleaning up your dependencies with protocols

Updated on: February 10, 2020

If you’re into writing clean, testable and maintainable code you must have come across the term “Dependency Injection” at some point. If you’re not sure what dependency injection is, that’s okay. I will explain it briefly so we’re all on the same page before we get to the main point of this post. Dependency Injection […]

Read post

Wrapping your callbacks in Promises

Updated on: February 10, 2020

A little while ago I wrote a post about PromiseKit. In this post I wrote mainly about how you could wrap API calls in Promises using the NSURLConnection extension that the creator of PromiseKit provides. Since writing that article I’ve had a bunch of people asking me more about PromiseKit. More specifically, some people wanted […]

Read post

Expand your learning with my books

Practical Core Data header image

Learn everything you need to know about Core Data and how you can use it in your projects with Practical Core Data. It contains:

  • Twelve chapters worth of content.
  • Sample projects for both SwiftUI and UIKit.
  • Free updates for future iOS versions.

The book is available as a digital download for just $39.99!

Learn more