Monday, May 17, 2010

First iPhone App

I finished development on my first real iPhone app this weekend! The application is very simple and is an extension of our MultiPaaS Web Application. The first app is an iPhone version of Coupons. Here are my impressions of the process and development experience.

The coding itself took only about 100 to 120 hours of total time, or somewhere between 2-3 weeks of full-time work. That was spread over about a month and a half of real time, mostly during the evenings. Working that way makes things take longer because of the context switch involved to get back into the mindset of the code (not to mention the activation energy!) Also, since I hadn't built anything in Objective-C or Cocoa before, I was learning a couple of very interesting technologies at the time. Overall, I think it's pretty reasonable to be able to build an app for a platform in such a short amount of time, and it says a lot for the framework and support that's available.

Speaking of support, I bought a book on iPhone development to help me build this app, and it promptly sat on my bookshelf for the past couple of months. I just don't learn that well from books — I'd much rather get in and start coding. I'll probably use it for some nice leisurely bedtime reading, and then I'll learn some of the right ways to do things!

The resources I did end up using were all online. The iPhone Developer's Guideand the iPhone Dev Center in general helped immensely. Plus, Xcode has the entire set of documents for iPhone development built in — rather typical for an IDE — so I did most of my library learning through there. And Google, of course. Most of the time I would just search for the answers, and most of the time, somebody had done it before.

For example, I used a modified version of Matt Gallagher's OrderedDictionary in the code, which was very helpful. Yes, I could have written my own version, but his was pretty good and only required a bit of modification for my own purposes.

By far the easiest part of the application to build was the UI. Not just the UI display development using Interface Builder, but the UI* classes are pretty easy to understand. In contrast, the most interesting and challenging part was the interaction with the MultiPaaS web site. And, surprisingly, once I used it for a little while, Objective-C turned out to not be so bad. There were many parts that frustrated me, such as the bracket notation and the lack of true encapsulation, but overall it wasn't bad. After all, it's just another programming language, and they all have their warts.

To elaborate a bit on the interaction with MultiPaaS, there were a couple of parts that I needed to work with. First, MultiPaaS is built on Google Web Toolkit (GWT) for its browser-based view and all of the remote calls with the server. That remote protocol is rather complex and not something I really wanted to reproduce within iPhone. However, I wanted to be able to reuse the methods that were exposed. Therefore, I decided to change the base class for the RPC implementations to provide a REST-based API as well. This proved to work out really well, especially since I already had a generic method to generate and parse XML for Java objects. The worst part was reproducing the Java beans in the iPhone app — now I have two copies of the same classes. Then I needed a way to convert from XML to Objective-C classes, and that's not something I found on the internet.

In addition, I didn't want to call MultiPaaS for every UI interaction on the iPhone since that would degrade the user experience considerably. Instead, I wanted to cache all of the data locally. I chose Core Data for this so that I could query the data, update it quickly, and even allow the user to store new coupons within the application's cache. That was also easier than I expected.

After development was complete, it only took a couple of attempts to get it into the App Store. Into, mind you, not approved yet, though hopefully that process doesn't require too much effort. I had already had to go through the hurdle of getting into the App Dev program so that I could test the app on my iPhone, so getting a distribution certificate proved to be fairly painless.

Speaking of getting into the App Dev program, don't try to do so as a Sole Proprietorship. They won't take it, even with a Texas Retail license. In the end, since I don't want to pay for incorporation fees at the moment, I had to put everything under my name. When there's enough interest, we may incorporate, but until then, we've been down that road before, and it's not really fun.

Here are a few screenshots of the upcoming app:


I'll add a link when it's available on the app store.

No comments: