Hot on HuffPost Tech:

See More Stories
Free Switched iPhone app - try it now!
AOL Tech

Dev Chair : iPhone SDK experience


The iPhone SDK has been out for couple of weeks now and I've been using it to develop an application for my work as a technology demonstrator. My experience thus far has been largely positive. I wasn't surprised by how well-made the SDK is, even at this beta stage. The amount of work involved in releasing any SDK, let alone one that is so tightly scrutinized, cannot be underestimated.

Consider that I am learning three new things simultaneously: programming in Objective-C, learning how to use Xcode, and what is available in the iPhone SDK, I am going to describe the whole experience instead of just confined to the SDK.


Xcode

The main problem I have with using Xcode comes from the years of experience I have working with Visual Studio and ReSharper. Almost all the most frequently used keyboard shortcuts are different between Xcode and Visual Studio/ReSharper. Some are similar or logical (build is Cmd+B, for example), but others are just completely different (show method list is Option+Escape in Xcode vs. Ctrl+Space in ReSharper, or next placeholder is Ctrl+. in Xcode vs. Tab in ReSharper).

I've also yet to figure out (or taken time to figure out) some of the most frequently used document navigation keystrokes in Xcode. Switching between code files in Visual Studio (or any word processor in Windows for that matter) is Ctrl+Tab. And to switch between Visual Studio and MSDN Help is Alt-Tab because MSDN Help is just another application in Windows. In Xcode, the OS X standard keystroke of moving between windows within an application (Cmd+`) does not work. This also does not work on the Xcode help documentation viewer. Nor Cmd+Tab! While I have the screen real estate on my Mac Pro to arrange both Xcode and help viewer side by side, I do not have that luxury with my Macbook Pro. Thus, I have to take my hands off the keyboard and use the trackpad/mouse every time I have to read the documentation, likewise with navigating through code and code files.

The Language
There is nothing wrong with Objective-C as an object-oriented programming language. Unfortunately as it is built on C, a lot of what is considered unnecessary nowadays remains. Why in the year 2008 would I am still required to have a header file and have to declare everything twice? The 'synthesize' keyword helps but it feels like a hack than a solution. And call me lazy but after working with newer languages (C# and Ruby) over past 6 years, worrying about pointers makes me feel like I'm back in the 90's. Similarly, having to manage my own memory allocation/deallocation takes away from the job of solving problem, instead I have to worry about the mechanics of programming. However, I completely understand why the garbage collector that is new in Objective-C 2.0 is not in the iPhone since the garbage collector is an extra process that may be too power hungry in a phone.

What has really slowed me down is the un-uniformality of the syntax. In C#, I can access class methods or properties in very similar way. For example,
// Method
bool result = Foo.DoSomething();
// Property
string name = Foo.Name;

You can see I don't have to worry about whether I'm going to call a method or access a property when I start typing. I start with 'Foo.' Then I can decide whether to use method or property after the period.

On the other hand, Objective-C uses different syntax.
// Sending a message to object (i.e. Calling a method)
BOOL result = [Foo doSomething];
// Property
NSString *name = Foo.name;

So I can't type 'Foo.' then decide what to do. I have to decide beforehand whether I want to use a method or property. It would be fine if Xcode code completion is clever enough to insert the square brackets for me if I type 'Foo doSomething', but unfortunately it does not. Thus, as I explore the unfamiliar territory of the iPhone SDK, instead of using the SDK features and concentrate on building an iPhone app I wound up having to take my mind off the problem and constantly moving back and forth to add/remove square brackets. Any competent programmer will tell you this can get a bit annoying after a while.

This is just my unfamiliarity with the Xcode environment and I am sure someone will quickly tell me what a moron I have been and point me to all the keystrokes! Similarly with Objective-C, I am sure I will get used to its syntax after working with it more over time. But this does illustrate the obstacle that developers who are new to Mac development will encounter.

IPhone SDK beta
Despite the 'beta' label, the iPhone SDK is pretty polished. All the infrastructure classes and controls are there, along with all the relevant documentation, to allow developers to build a great looking iPhone application. Apple has also provided some great iPhone sample apps to show us the way. I was able to build a simple application using the table view within matter of hours, just by reading the documentation and looking at the sample apps.

But after digging a little deeper I have found that some standard iPhone controls have not been included in this beta. For example, the editable table cell in the Preferences app with the text label on the left and text field on the right? Sorry, you will have to build that yourself. The "+" button at the top right corner of the Calendar app? Sorry, you will also have to build that "+" image yourself. How about the up and down arrows in the Mail app? Same there. The large nice looking green button in the Clock application? You guessed right. You will need to create your own green bitmap and stretch it out for the button. Why is this not just a property of the UIButton class? All I want is a standard looking green (or red) button with some white text. The only things that I should need to do are: create the button, set the color(s), set the text and that's it.

On the other hand, integrating your application's preferences and settings into iPhone's Preferences app is very simple and straightforward. Similarly accessing contacts, photo library or location is very simple. And the Multi-Touch Cocoa makes it very simple to handle touch(es) events in the application.

Right now, the flexibility of the SDK is geared much more towards developers who want to create non-standard looking applications such as games. Hopefully, when June comes Apple would have added all of these standard controls to the final release of the SDK so I would not have to spend time creating bitmap images, and spend more time creating applications instead.

Another major omission in the original SDK is the Interface Builder for the iPhone. While it slowed down beginners such as myself initially as I cannot just drag and drop UI controls and connect up events, what I lost I gain in understanding how the framework works. Interface Build is now included in the latest iPhone SDK beta (build 9A2151).

Final thoughts
Reading my experience so far, you might get the impression that I do not like the iPhone SDK development environment. That could not be further from the truth. Despite all the issues I had, this last three weeks has been one of the most exciting development periods I have had in a long time.

I suspect that many Windows developers will find working with iPhone SDK, Xcode, and Objective-C a relatively painless experience. And many great applications will be in the iTunes App Store in June when it opens its 'door'. Unfortunately, I fear that the big difference in keyboard shortcuts and language constructs may prove to be too high a cost for the more casual developers to overcome and become a dedicated iPhone developer.

Tags: apple, c#, iphone, iphone sdk, iphonesdk, objective-c, resharper, visual studio, visualstudio, xcode

Comments

13