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