Friday, September 27, 2013

Learning Objective C

The first thing that I had to do was learn Objective C. Coming from a deep background in Java, I find the language at once familiar and at the same time deeply disconcerting. Its got automatic memory management, sort-of, through ARC.

Perhaps the absolute most wierd thing is the method invocation syntax, which for some reason involves brackets:

[myInstance sayHi: @"hi!"]

... is the equivalent of myInstance.sayHi("hi").

Its very very weird to use brackets for something other than referencing some part of an array. The other bit of wierdness is the usage of - and + symbols to indicate class (static) methods, and instance methods:

+ (int) myNumber {...}

... is the equivalent of  public static void myNumber().

Fortunately the similarities in loops and if..then.. else with Java and C have so far made the transition pretty smooth. I am eager to explore the object oriented aspects of the language, which might be the subject of my next post.

No comments:

Post a Comment