swift


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 …

Swift 5.5: Replacing GCD With Async/Await Read More »


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 …

Little Swift Tricks: Boxing Multiple Types Read More »


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 …

Green Is Home Base Read More »


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 »