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