Evolution of my asynchronous networking code

In 2010 I used synchronous NSURLConnection‘s, completely blocking the UI (time pressure). In early 2010, I was working on a pre-existing app the did use asynchronous connections, but would block the Back button of a UIViewController until all completed. This was something the product managers really wanted fixed.

My solution used concurrent NSOperations (of which I’d had some prior experience). Using the “cancel” feature of operations, it was possible to stop all background operations when the user clicked the Back button and cleanup. It turns out there are many “corner” cases in the design—for instance, the user cancels before a queued operation has started running. Since the app also showed a spinner when the operations were running, the feature had to let the controller discover how many operations remained, in particular if all operations were complete.

Thus, in late winter, 2011, I had coded this feature into a UIViewController subclass, it was working pretty well, and I took what I’d learned and created an open source testbed for concurrent NSOperations on github, Concurrent_NSOperations, supporting both Mac and iOS targets.

This project allowed me to really flesh out the logic – the UI lets you choose the sequence of events (e.g., cancel before operations starts), and it let me catch and deal with many edge cases.

Open Source Journeys

I started working with Objective-C on the Mac in 2004, and mostly switched over to iOS in 2010 (because as Willy Sutton said, “That’s where the money is”. In 2007 I interviewed with Google in Zurich, and failed to get an offer due to a deficiency of C++ in my background. I resolved to fix that and picked up an open source project languishing on SourceForge, xlslib (it lets you create Excel .xls files). That was my very first project, and one I never had the chance to actually use myself!

Since then I’ve published a slew of open source projects, mostly on github, and ones I now use extensively myself. I plan to discuss these projects here, as the README files on github just don’t seem to generate much interest.