Tag Archives: Swift

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

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

Analyzing a dependency graph in Swift

I published my solution to Dave Thomas’s Transitive Dependencies programming exercise, known as a kata, to GitHub: https://github.com/ijoshsmith/transitive-dependencies-kata The Challenge This exercise involves analyzing a graph data structure which contains nodes that “depend on” other nodes. A graph is represented as direct dependencies between nodes: The objective is to find all … Continue reading

Posted in Swift | Tagged , | 1 Comment

DRY Fusion data munging kata in Swift

I worked through one of Dave Thomas’s programming exercises, called a kata, and pushed my Swift 2.2 code to GitHub. The code shows how to apply the Don’t Repeat Yourself (DRY) principle to two similar but different data processing programs. The end result of … Continue reading

Posted in Swift | Tagged , | 1 Comment

Creating an iOS Wizard UI in Swift

I published a reusable framework, written in Swift, for implementing the Wizard UI design pattern, named Wizardry. It simplifies creating a user interface composed of multiple view controllers that enables the user to complete a task. This is a particularly important UI design pattern for mobile apps … Continue reading

Posted in Swift | Tagged ,

Find keys by value in Swift dictionary

Here’s a helper method that might come in handy when working with a Swift dictionary. It finds every key mapped to a particular value. This is similar to the allKeysForObject(_:) method of NSDictionary, but it is generic so it can return … Continue reading

Posted in Swift | Tagged