swift


Architecture Is About Making Easy Things Harder

In iOS development, there’s always been a fight over Controllers. The path of least resistance, when you have a piece of new logic to add, is to just throw it in the Controller. Every Apple WWDC for years would pretend this is how you add this new API. Drop in three lines, ship it. The […]


Swift 5.5: Replacing GCD With Async/Await

Multithreading! The mere word sends shivers up one’s spine. And if it doesn’t, it should. Main thread and background threads. Code that runs asynchronously. Code that can run simultaneously with other code. Code that can run simultaneously with itself. Code that can share data across threads — possibly with disastrous consequences. Concurrency. Multithreaded code is […]


Little Swift Tricks: Boxing Multiple Types

Here’s a little Swift language trick I sometimes use — more often than you might suppose, actually. As I’m sure you know, Swift is very strict about the types of its objects. You have to declare clearly what type a reference is, and from then on, you have to stick to that. That’s one of […]


Green Is Home Base

A developer’s typical working procedure is: Create a feature branch off of master. Implement the feature, which will destabilize the code… Then, spend time getting everything back into a working state. It’s as if you needed to replace a part in your car that is buried deep inside of it — so first, you have […]


Rant: Swift, Cocoa, Target–Action, and Instance Property Initialization

As someone who spends a lot of time hanging out on Stack Overflow, I get to see first hand what traps iOS Cocoa programmers fall into. In fact, that’s why I spend a lot of time hanging out on Stack Overflow. It’s fun and instructive. But it also pains me to see people making the […]


Swift 5.2: No More Unsafe Pointer References

When people upgraded to Xcode 11.4, a lot of complaints started to appear on StackOverflow that code of the following form was giving trouble (this is an odd way to write this, but just bear with me): let color = // some UIColor var r = 0 as CGFloat var g = 0 as CGFloat […]


Swift 5.2: Keypaths Get a Promotion

When you’re busy programming, it’s easy to sleep through changes in the Swift language, especially minor changes; and Swift 5.2 (which emerged as part of Xcode 11.4) was definitely minor, especially in comparison with Swift 5.1. Still, this is an interesting little improvement worth knowing about. Suppose that a Person has a firstName and a […]


Get Started With Swift Packages

Encapsulating code so that you can share it between your own projects and with other programmers has always been a bit tricky in Xcode. You can write a framework easily enough, but sharing frameworks between apps is not simple, and it’s even harder to distribute your code to others as a framework, and for others […]