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
Blog
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
iOS UI/UX elements – for designers
Working on a lot of iOS apps means working with a lot of designers. One of the most common questions I get from those designers is "How do I make these designs easy for you to implement?" My answer is invariably: skin the existing iOS UI/UX elements rather than create your own. Unfortunately, that advice… Continue reading iOS UI/UX elements – for designers
Quick Swift: Operators
Operators are just a special type of function that can help make your code easier to read. Operators you might be familiar with include +, -, and even ??. They come in three flavors: prefix, infix, and postfix, depending on where you put them with respect to their arguments: Prefix operators go before their (only)… Continue reading Quick Swift: Operators
What makes a good network layer
Here's what I want in a networking layer: Should be easy to switch between different hosts and API versions while keeping all the endpoints the sameShould be possible to separate the logic for setting up a network call and firing itShould be easy to mock server responsesShould be easy to separate concerns when handling responsesShould… Continue reading What makes a good network layer
Slippers: a library for paging, refreshing, and JSON
Slippers is not a networking library. It won't make server calls for you (I have other libraries for networking). What it will do, however, is make it easy for you to trigger network calls when you need to. It does this by providing some protocols and simple implementations thereof to control common network tasks like… Continue reading Slippers: a library for paging, refreshing, and JSON
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)
Coronemoting: Remote work during the coronavirus pandemic
Hello! Your company is probably remote now due to coronavirus/COVID-19. As a full time remote worker, I have some advice (and encouragement!). First, though, a caveat. If COVID-19 is causing your first experience with remote, understand that this isn’t normally how things go. This situation sucks, period. Even I'm not getting as much done, simply… Continue reading Coronemoting: Remote work during the coronavirus pandemic
When did New Yorkers start taking COVID-19 seriously? An analysis based on subway app usage
My company owns a bunch of subway apps, but one of our most popular ones is SUBWAY:NYC. Obviously, this app in particular has seen dramatic decreases in usage as a result of the worldwide pandemic that's hit NYC especially hard. While that's bad for me, I thought it might be interesting to look at the… Continue reading When did New Yorkers start taking COVID-19 seriously? An analysis based on subway app usage
Coronavirus: a mathematical prediction and what you can do about it
Caveat: I’m not the CDC. I’m just a former math professor who had a long flight last week and wanted to figure out the odds that someone on my plane had coronavirus. That said, the model I describe below is a reasonable approximation of the situation we're in for the time being; that is, unless… Continue reading Coronavirus: a mathematical prediction and what you can do about it