In the recent months I was working mainly on iPhone projects in my spare time abd recently I was lucky enough to cut some iOS code for work too! Definetly time to blog about my encounter with Objective-C, XCode the Cocoa and all the other wonderful things that come out of Infinite Loop 1 in Cupertino…
My first encounters with the iOS environment about 2 years ago left me with a feeling of ” wow this is old style!”. Header files, pointers, no automatic memory management… It took several attempts to actually get into it. I quite like reading a book about a programming topic. That’s the reason I picked up a book by Aaron Hillegas about Cocoa and OS X programming. It is definitely a good idea getting a basic understaning of Objective C and Cocoa before delving into iOS.
Cocoa tends to use helper classes and delegates instead of inheritance to build frameworks. This is described as the KITT versus Robocop approach by Aaron Hillegas’ book. You have to read it yourself to appreciate the analogy (did I mention it is a good read?). That is something I have defintitely taken over in my day to day .NET programming. If detaches your design from the class hierarchy.
Some other concepts like Categories and Key Value Coding can be found in .NET in a much more refined version. It is however refreshing to see how simple you can achieve similar goals.
Memory management is definitely the hardest part of the iOS journey for me. Having to allocate and free memory has not crossed my mind for a long time. Cocoas approach (using a retain/release) model makes it however bearable.
You are rewarded with a remarkebly productive environment. The power you gain from beeing “close to the machine” has surprised me. I have long defended the claim that todays Java and C# jit compilers build executables that are as performant as native compilers. Although I have not measured my obersvations I beileive on small devices the difference still matters.
If you want (or have to) develop for iOS you have choices these days. However in my experience it is hard to beat the results you get from using XCode, Objective-C and Cocoa. Give it a try.