Friday, June 22, 2012

Objective-C First Impression

I don't like the NS prefix. Ugly.

The Protocol is the Interface in Java. Here is the key sentence to understand it.
When you implement the methods of a protocol in one of your classes, your class is said to conform to that protocol.
 #import is to import a header file, not just a class or interface. Preferred over #include.

Java class has everything in one .java file. Objective-C class has its interface portion in a .h file, its implementation portion in a .m file. My understanding so far is that it is not possible to initialize any member variables in the .h file. Not mention any static final variables.

Type id is like the class Object in Java.

OK, if not a type id for a variable, it is so-called strongly typed, you need to have * at the head of the variable name. Ugly.

So the class method is the static in Java. Seems no concept of Constructor so one class method to create new instances is always necessary.



No comments: