The iPhone is a fabulous device, few people will argue about that.

But…

When I started developing iPhone apps about a year ago, it felt… awkward. If you want to create an app for the iPhone, you have to use Objective C, which was invented sometime around 1934. I’m kidding of course: it was 1986, but that’s a small detail.

Apart from the odd syntax (which is fine, other languages have odd syntax as well), I was amazed by the lack of basic language and framework features we take for granted these days.

To illustrate the contrast, I’ll show a small function that strips the time portion of a date, written in Objective C:

+ (NSDate *) stripTime:(NSDate *) date {
   NSCalendar *gregorian =
         [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

   NSDateComponents *components =
          [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit)
                       fromDate:date];

   date = [gregorian dateFromComponents:components];

   [gregorian release];

   return date;
}

The same thing in C#:

public DateTime StripTime(DateTime date)
{
    return date.Date;
}

I guess I have been spoiled by C#. Can you imagine what it would be like to consume a SOAP webservice from Objective C? Well, check this out. (I have to admit: it received a 5-star rating, so I guess it was worth the 62 hours spent on it)

PS. I realize I suck at Objective C, and I’m sure a better Objective C developer can shave off a line or 2 of my code, but you get the picture…

Thank god a few geniuses over at Novell created MonoTouch

Share this article:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Twitter
  • DotNetKicks
  • DZone
  • LinkedIn
  • Reddit
  • Tumblr