Jun 22 2010

My First Look at Objective-C

Category: iPhoneJoel Ivory Johnson @ 03:14

I registered for iPhone development almost a year ago and haven't done a danged thing with my registration since this. This weekend I finally decided to take the time to look at it and willful decided that I would neglect most of my weekend demands in favor of learning something new. I've heard a lot about Objective-C (primarily from people that don't use it on a regular basis) and primarily wanted to experience it for myself.  I keep hearing the phrase "It's C trying to be like C++." That's usually said while some one is declaring that Objective-C is not a good programming language. 

My thoughts? I see where the phrase "It's C trying to be like C++" came from. But I'm not going to agree (or disagree) with the statement. When developing in C++ the VTable and other information about the class is pretty much abstracted away or not  accessible to other pieces of code. C# by contrast shares much of this information through the Type class and other metadata objects that one can probe. In Objective-C the class data is actually stored in a struct. An object of type X will have a reference to the structure that defines  members of X. One can walk through this structure, examine the child members of a class, and so on.  

There were some other things that looked notationally cryptic at first but quickly started to make sense, such as one syntax available for calling methods. In the C languages one might see a call like X.DoY(); but in Objective-C one may see it written as [X DoY].

As per usual if I do a lot of reading on something I'm going to end up writing something down. In this case you can see the collection of my notes as an article on Code Project in a getting started article ( http://www.codeproject.com/KB/iPhone/iOSGetStarted00.aspx ). If you see places where it can be improved then be gentle with what you say; this was my first time looking at iOS programming. So I'm sure there are a few things I've missed.  I might come back and read more about Objective-C and eventually write something else. But for now I'm going to return to my concentration and finish up some Windows Phone 7 projects I'm working on.

Tags: ,