she swears <i>geek</i> is a term of endearment

Adventures in iPhone SDK development, Objective C

I’ve heavily embarked on my journey into iPhone sdk development and have made tremendous progress as I slowly iterate through v1 of our Ockham Research Idea Generator.  The experience has certainly humbled me and made me appreciate Visual Studio more.  I am not a C++ programmer so I must start from ground zero and learn a number of things I already know how to do on other platforms and in other contexts.  Its frustrating to consider yourself an expert in software design and engineering yet find the simplest problems elusive and hard to overcome.  This such as setting background colors, initializing screens, converting variables, appending strings, memory management and object construction are all common, basic concepts but have proved unusually inaccessible coming from a Microsoft and web development background.

I hope others may grow as I go

I plan to post regularly about the things that I learn about developing for the Mac OS platform.  Specifically, I am targeting iPhone but most of the concepts are applicable.  Objective C is the language of choice for iPhone development, although you can also use C or C++ (though I haven’t tried).  Objective C is weird, no other way to put it.  The latest Obj-C supports dot notation for properties but I just find that convenience confusing and inconsistent.  "Do or don’t," I say.  Rather than dots, you pass messages using brackets.  The messaging capabilities are interesting and powerful.  The brackets become familiar after a while and the common conventions start to look rational once you’ve been staring at it long enough.

iPhone is Cocoa

The short of it is: if you don’t find an answer in iPhone resources, try Cocoa resources, forums and docs.

Cocoa is the mac framework built in Objective C and is pretty much the equivalent of the Microsoft.Net framework.  You build against the framework and your app benefits from the abstraction of details that you should not have to care about.  It evolved from the NextStep platform developed by NeXT around the time the Delorean first went back to the 50’s.  While the full OS X Cocoa platform has modern features like automatic garbage collection, the iPhone OS is stripped of these novelties.  It is remarkably easy to crash your app doing nothing more than loading lists.  Once I’ve gotten a little further, I will pick up a good book on Cocoa development and familiarize myself with where this all came from.  I’m sure that will help.  If you have the time, do that.  Otherwise, I hope you can gleam enough from me and others like me to clamor through the bits you need.

Objective C

I really don’t care to add more languages to my alphabet soup list of 1001 ways I can skin a cat.  Nonetheless, I now have another C based language to paste into my presenter bio.  If it were really interesting like Ruby, or really prolific like PHP, I’d be less irritated.  Sorry, I am irritated.  I am sure I’ll find the magic books/forums/tutorials that answer all the questions I’ve had but, for now, its like I am trying to join some secret society where I have to prove myself before I’ll be granted my practice manual.   The thing that makes it hard is that Apple seems to be telling folks not to help them educate and share with the community.  Apparently, posting tutorials violates their NDA.  I hope I don’t get an email stating that my opinion is covered in Section 4a of the developer agreement.  I will check just to be sure :)

Resources are hard to find

The advantage that Ruby, Php, Javascript, JQuery, Python, Xsl, C#, yadda, yadda, yadda have is that you can Google for answers.  Objective C documentation is often behind a password so that single, tiny, obscure, wonderful tidbit of eureka is buried in a 300 page Tome that you cannot see unless you log in.  Therefore, simple things are difficult to figure out. 

When you do find something, its nasty

Here’s the thing that’s really tarnished my opinion and caused these many paragraphs of whine…  No offence to all the bright, clever YouTube kids out there who spent their summer hacking the iPhone instead of lighting their GI-Joes on fire like I did (in fact, many kudos), but a decade of programming has taught me a lot about how to program but even more about how not to.  I’ve learned though trial and error, and more error, and how the hell to I troubleshoot this error, how to structure my programs so that its less costly down the road when something needs to change.  Its not a matter of if, its a matter of when, will it will change.  When it does, you’ll either be glad you took the time to design strong object oriented concepts and design patterns into your program or you’ll be very angry that you (or someone else) didn’t.  Unless you need practice cursing or just want to expand your slang vocabulary, you’ll want to practice good design.

The iPhone tutorials out there will get you from XCode to button click but should you really load the next view in the event handler of a button click?  And should you load all the data that your view needs inside the loadView method of the View?  The answer to that is, "No."  This is not the place for design patterns and such but I will try to cover that going forward.  You can design iPhone software well, its just not the default.

I’m a Windows programmer who switched to Mac for all its charms

I’m still a Windows programmer and I love Visual Studio now more than ever.  I love C#.  I absolutely enjoy programming web applications and services on the Windows platform.  I derive great pleasure from launching Vista inside VM where it can do me no long term harm.  I delight in having the ability to continue working while being Vista’d as Windows updates cripple my Windows VM.  When I am not programming, I love to surf the net using Safari, watch TV on my AppleTV, or do just about anything on the iPhone. 

While Microsoft spoiled me with Visual Studio and massive developer support, Apple is the expert in consumer devices and user interface.  Perhaps there is some prestige attached to being a Mac/iPhone developer.  On the other hand, I would like to build upon the strong community I have experienced in the MS development world and perhaps build some of that in the iPhone developer arena.

My next post will be technical.  This one was just to explain why (and get it off my chest)

3 Responses to “Adventures in iPhone SDK development, Objective C”

  1. I am new to iphone development. can I do it on windows?

  2. I am new to iphone development. can I do it on windows?

  3. I don’t recommend you do it on windows. The window might break and you’ll cut your booty.

    OH! You mean develop on the Windows platform. My mistake. No, you must have a macintosh to develop iPhone native applications. You can develop web apps using iUi (just google iUi iPhone).

    Pros: Use your platform and web framework of choice
    Reuse existing assets from your regular website
    All the goodness of web apps
    No Objective C
    Reliable documentation to get you through it

    Cons: Can’t take advantage of iPhone native capabilities (yet)
    No distribution through app store

    I only recommend pursuing native Objective C iPhone app development if one of those two cons of web app development is significant to you or you are or have a Cocoa expert at your disposal. Expert, mind you, expert. Its a PITA and doesn’t get better with experience. Its like arthritis, its not getting better, you’re getting used to it.

Leave a Reply