Blog

Uncategorized

Making UIKit Functional-Programming Friendly

I've become quite the functional programming advocate, but one difficulty I often face is the prevalence of Object Oriented code throughout the iOS platform, and perhaps most obviously in UIKit (I'm not going to talk about SwiftUI here – it's still too new for production in my opinion, though of course I'm looking forward to… Continue reading Making UIKit Functional-Programming Friendly

Uncategorized

Swift Custom Operator Spotlight: Optional Casting

I don't know about you, but I often find myself casting objects in Swift. This used to involve writing code like this: if let myDataSource = tableView.dataSource as? MyDataSource { doSomething(to: myDataSource) } This is especially annoying when I'm using a functional programming style, as that entails writing a lot of functions, and casting parameters… Continue reading Swift Custom Operator Spotlight: Optional Casting

Uncategorized

Swift Custom Operator Spotlight: Optional Unwrapping

How often have you written code like this: var object: MyObject? ... if let unwrapped = object { doSomething(with: unwrapped) } Or, worse, in order to minimize indentation or because you're relying on a library you don't control, how often have you written a function like this: func optionalDoSomething(with myObject: MyObject?) { if let unwrapped… Continue reading Swift Custom Operator Spotlight: Optional Unwrapping

Uncategorized

Quick Swift: Combine (Just the Basics)

There are three things you generally want to do with Combine: publish values, manipulate those values, and receive those values elsewhere. Let's see how we can do each of those. Publishing Values Values are published with, predictably, Publishers. The most common way I see this happen is through @Published fields. So, for instance: class App… Continue reading Quick Swift: Combine (Just the Basics)