Completion Handlers in Swift

Completion handlers are everywhere in Swift. They are commonly used in Apple’s frameworks and many third-party libraries. They are often put forward as an alternative to delegation and the target action pattern, especially in the context of long-running work like fetching data over the network or processing images. You might see them referred to as “handlers” or “completion blocks”, simply “completions”, or maybe something else depending on the conventions of the code base you are working in....

October 22, 2022 · 14 min

Stop Throwing Away Errors

We all know how it goes when we are trying to get something working. We want to get there as fast as we can and we get focused on the “happy path”. Maybe we’re not that familiar with the technology/language/concept, but we have one specific goal or task we are trying to achieve and we don’t care so much about the edge cases or what will happen when things go wrong....

August 27, 2022 · 14 min

5 Reasons to Use Typealias

Swift has many features that allow us as the users of the language to customize how we write code, while still giving us all the protections of a statically typed language. Today we’re going to talk about one of those features which seems small, but it packs a lot of punch. The typealias keyword lets you define a “type alias”, a custom name for a class, struct or any other existing type in Swift....

May 25, 2022 · 8 min

Writing Short Code Isn't The Point

I don’t know about you, but I have spent a lot of time trying to write code in the shortest, most elegant way possible. I have put a lot of thought and time and effort into it over the years. And I see it a lot in other people’s code as well. I have seen it from both junior and senior developers. I have seen it in new code bases and mature code bases, both large and small....

March 13, 2022 · 9 min

Algorithms in Swift - Intro

I am looking for an excuse to learn more about algorithms, so I am going to write a series of posts that cover some of the most common ones and examine at what they might look like in Swift. I know algorithms often feel like an academic topic – something for nerds in computer science classes. They can be intimidating because their explanations and examples tend to be math-heavy and there is a lot of hard-to-decipher jargon out there about them....

January 14, 2019 · 10 min