What I learned while developing for the iPhone

Categories: Adobe Flex AS2 AS3 iPhone Objective-C XCode

Now that MASH, my first game for the iPhone and iPod touch, has been in the App Store awhile (more info here: http://magnatemobile.com/apps/mash), I thought I’d take a moment to jot down some of my thoughts on the experience and what I learned, not having done Cocoa or Mac development previously.

I came to Objective-C having had the bulk of my programming experience using scripting languages like ActionScript (AS2 and AS3), JavaScript, and PHP, as well as a fair amount of C# and Java. The transition to C style syntax and methodologies wasn’t a giant leap, but there was definitely a learning curve involved. These are some of the things I learned.

Coming from Eclipse-based IDEs, I was used to having the file and folder structure of my project in the editor match up to the structure I’d see in Finder (or Explorer if I was on Windows) - in XCode, though, you can arrange and re-arrange the files and groups within the editor without actually changing the location of the corresponding item in the filesystem. I’m still not sure if I like this - there are times when I want to re-arrange files (especially the location of graphics) in my project using Finder’s column view instead of XCode’s list view.

Know when to retain and when to release. Releasing an object that you needed to keep will cause your program to crash. Seems like a no-brainer, but not understanding why my app crashed when I would invoke a “Start Over” method I created had caused me to spin my wheels for about a half hour. Additionally, take care not to “over-release” an object - the console will spit out malloc warnings that aren’t self-evident as to their cause.

When it comes to creating an app from the get-go with multiple languages in mind, creating a Strings file first and then using NSLocalizedStringFromTable is one way to do localized strings, but isn’t necessarily the conventional way. After having implemented localized strings that way first, I later learned that XCode has a process for writing your code first with the strings you intend to use, and then allowing the compiler to handle creation of the necessary files.

XCode does a very nice job with HeaderDoc documentation. It’s much easier to use than Flex Builder and ASDoc, in my experience. HeaderDoc doesn’t try to document every class in your project like ASDoc does by default, just those you tell it to.

You may have heard horror stories about long waiting times and applications rejected for seemingly trivial or vague reasons - while that hasn’t been my experience, I will say that the process for submitting an application is less than ideal. It takes a lot of time, forms ask for information in a strange order (this isn’t exactly the process, but on some form pages it’s a little like: enter the information about your app, then choose graphics to upload; after clicking to upload the graphics and the page refreshes, the previously entered form information is wiped out and you have to enter it again - frustrating!). Submission to approval time for my app and updates have been fairly quick so far, less than a week from “In Review” to “Ready for Sale”, so I don’t think I can complain about long waits, although the anticipation of not knowing if your app will be approved or rejected is bad enough.

Overall, I’ve enjoyed the process of learning to develop for the iPhone. I’d imagine the learning curve is probably steepest for those without previous object-oriented development experience, but for anyone with a good idea and a willingness to learn (and shell out for tooling and a developer certificate), I’d say the effort has been worth it.