Author Archives: Josh Smith

About Josh Smith

Josh Smith is a musician at heart, and a software developer by obsession. He lives in Arizona, plays classical music on the piano, jazz on the guitar, and enjoys brutally long rides on his bicycle. He has a wonderful wife and thinks that, in general, life is good.

Reflectable enums in Swift 3

Suppose you are working on a Swift program that needs a data model to represent a contact, such as a person from the user’s address book or a FaceBook friend. You might start off by modeling this as a Contact … Continue reading

Posted in Swift, Uncategorized | Tagged | 10 Comments

Generate Equatable code in Swift

Here is my Swift 3 utility function for turning a live class/struct instance into Equatable protocol code for that type: https://github.com/ijoshsmith/equatable-code-generator Here’s to never writing that kind of code ever again!

Posted in Uncategorized | Tagged | 1 Comment

Function composition in Swift

The way that functional programming languages allow functions to be combined can help make code easier to read and understand. The technique is known as function composition. I show how to compose functions in Swift 3 using custom operators, including a … Continue reading

Posted in Uncategorized | Tagged , | 1 Comment

json2swift: a peek under the hood

This article presents a high-level overview of how my json2swift tool works. Several people have expressed interest in using my code as the foundation for a similar tool, or just want to change the Swift code it generates, and have asked … Continue reading

Posted in Swift | 1 Comment

Swift JSON library vs. code generation

Ever since Swift was first released there has been an endless stream of new libraries to simplify writing Swift code that consumes JSON data. Since this is such a common and tedious aspect of developing apps, it’s an important topic … Continue reading

Posted in Swift | 6 Comments

Create Swift data models from JSON

I published a tool that analyzes JSON data and generates Swift data model code, named json2swift. This tool helps eliminate most of the error-prone grunt work involved with consuming JSON data in a Swift app. The repository’s README has more … Continue reading

Posted in Swift | 1 Comment

Concealment design pattern in Swift

This article introduces a design pattern that I call Concealment, and demonstrates how to use the pattern in Swift code. Purpose The Concealment pattern enables types to support novel, related functionality without adding nonessential members to their interface. Motivation User-defined types can easily be overused in a codebase, giving more prominence to … Continue reading

Posted in Swift | Tagged | 1 Comment