swift


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 …

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


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: No More Unsafe Pointer References Read More »


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 …

Swift 5.2: Keypaths Get a Promotion Read More »


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 …

Get Started With Swift Packages Read More »


Swift 5.3 and Trailing Closures

As I write this, it’s still less than three months since WWDC 2020, and Swift 5.3 is still being licked into shape. It’s not terribly revolutionary; here are a few highlights: @main instead of @UIApplicationMain, and the ability to declare a @main struct in place of a main.swift file (SE-0281) Synthesis of Comparable conformity for …

Swift 5.3 and Trailing Closures Read More »


Cool Swift Tricks 4: That’s an Order

This is the fourth of four posts about random little Swiftisms for you to amaze your friends and confound your enemies. The Swift language has a lot of cool features hidden away in its nooks and crannies, but most real developers are too busy getting real work done to keep up with all of them; …

Cool Swift Tricks 4: That’s an Order Read More »


Cool Swift Tricks 3: The Garden of Forking Key Paths

This is the third of four posts about random little Swiftisms for you to amaze your friends and confound your enemies. All of these came up in my real code recently, and they really did surprise one or more of my co-workers. The Swift language has a lot of cool features hidden away in its …

Cool Swift Tricks 3: The Garden of Forking Key Paths Read More »


The Joys of Logging

It’s no secret that I’m a huge fan of what I call “caveman” debugging, also known as logging. Real debugging involves breakpoints, stepping, examining the call stack, looking at variables, talking to LLDB; it’s powerful stuff, and should be part of every Xcode programmer’s toolbox. But sometimes the simplest way is to drop yourself a …

The Joys of Logging Read More »