This post is in response to the iOhYes podcast #98 We Heard You Like Rants
Apple’s Best Practices
When Apple publishes sample code, they have to cater to their audience. They can’t expect to publish sample code that only 1% of readers can immediately take it and roll with it. Intead they employ a common publishing tactic known as lowering literacy to minister to a broader audience. In this manner, Apple’s sample code won’t be glistening with SOLID design or highly composable elements but instead will be a popular, actionable source for most developers.
The following is a synopsis of a crash that stumped my team for several days, and the process we took to investigate such bizarre behavior and ultimately diagnose and fix the problem. I’ll go over how we arrived at our solution and the debugging steps we took to get there. Hopefully by the end of the story you’ll have learned something along the way.
You may not be surprised when I say that I’m taking a break from learning Reactive Cocoa. Several of my coworkers are diving into swift, and with the imminent release of Reactive Cocoa 3.0, I decided to switch gears.
Asynchronously Loading Images
One of my first endevours into the realm of expanding my
RACObserve-fu was to asynchronously load a
UIImage from an image URL that was returned from the movie API in order to populate thumbnails in table view cells. Historically, using
AFNetworking’s built-in mechanism or a third party caching library such as
SDWebImage would work perfectly fine, but I wanted to stick to my guns and fully gulp the Reactive Cocoa punch that I’ve so graciously poured.
Baby’s First Monad
Since this is an app designed to pull down recent showtime listings from the Internet¹, I realized I’d need a network request in order to fetch the data and populate a listing of showtimes. In this case, a simple array to populate a tableview with the movies that are playing for each theater. I didn’t want to waste time building the entire API before digging into the app, so I spun up a dummy heroku instance to return some hard coded values. At this point, my muscle memory is nearly wired to pull in something like AFNetworking and start making GET requests. Before I knew it, I had a podfile and a view model ready to go; but quickly realized that I’m supposed to be doing this the Reactive Cocoa way.