Swift: Verify collections with sized index sets
In this post, I implement a rather slippery concept in Swift: index sets with exact sizes.
Why?
Partly because it’ll let us stretch our Swift-muscles a bit.
Partly because the use case presented here actually came up (more or less in this shape) as part of my work, and I found it to be an interesting little puzzle.
To understand what I mean b...
Magic version bumps for Github PRs
This post is about a configuration that I added to my a Github repo that I’m working on to make it automatically commit a version bump whenever someone merges a PR with a special label, and the hoops that I had to jump through to make it work.
For the tl;dr, skip to the last section (“Final solution”).
The problem
The idea was born from a fru...
An easy-to-use routing system in Swift
How we eschewed pre-built routing frameworks for a hand-rolled system based on protocols, enums and default implementations that is tailor made to our codebase
Developing software is a process, and so is becoming a better developer. I have fallen in most of the pitfalls that I have encountered on the iOS development trail so far, and I’m still ...
Swift: De-duplicate Tedious Type Declarations with In-line Configuration
Adding a configured method to variable types to help you organise your code while keeping things concise.
Closure initialisation
In our Swift codebase, we make extensive use of the “closure initialisation” standard. For example, instead of writing this:
private lazy var nameLabel = UILabel()
override func viewDidLoad() {
super.viewDidLo...
Swift: moving generics types from angled brackets to factory method parameters
Generics are powerful and expressive, but occasionally, they can get a little ugly. This article suggests a simple way to instantiate objects of generic types in Swift so that the roles of the generic types are clear, and to allow for more visually pleasing formatting.
Now, I’m not saying that generics are always unintuitive or ugly. Anyone w...