Having spent the last few weeks doing iPhone development, it’s been quite a culture shock. I expected to have a learning curve with regards to Objective-C. My last experience with C/C++ was back in college and I never did any GUI programming in it. I knew that XCode was pretty powerful and Apple had made Interface Builder to aid developers in building UIs. So I thought I would be able to flounder around and pick things up quickly. After all, I wasn’t doing some sort of cool game, I was just doing plain old data entry apps. So lay out the UI, wire it up behind the scenes and boom, you’re done. Right?
Not so much.
While it’s true that Apple provides a GUI building tool, it’s pretty bare bones and is really meant for extremely basic applications. For example, take the follow screenshot from the awesome app Trapster:
The UI above is actually non-trivial. The entire screen is a subclass of something called a UITableViewController. The grouping of sections with headings is officially supported out of the box, but the rows that contain a label and a textbox actually require a custom sub class of UITableViewCell. You need to specify geometry coordinates, spacing, etc… Not that it’s a HUGE task, but non-trivial and certainly unexpected, perhaps naively, by me. You end up having to write a ton of boilerplate code and making it reusable should be a high on any iPhone developers priority list to avoid cut-&-paste coding.
So, in order to give back to the iPhone SDK community that’s helped me so much over the past few weeks, I’m going to be posting some generic pieces of code that show how to do common things that you see in many apps, but that are not necessarily straight forward.