I was hoping to make a list of some of the differences in terms between java and objective c to abate my confusion. It makes explaining my difficulties easier when I know what things are called.
For example:
- null - nil
- this - self
- map - dictionary (not even quite sure about this one)
What I'm looking for are similar comparisons or corrections to ones I have listed. Not just limited to elements in the language, but concepts as well...
You're right about map = dictionary. I'll add:
- @public, @private, @protected (the default) are for instance variables only (not methods) and work like C++'s visibility modifiers (i.e. you declare them as section headers rather than before each variable).
- Class methods are like static methods in Java
- There are only two data structures: NSDictionary and NSArray (in immutable and mutable variants). These are highly optimized and work well for most situations. For everything else, there's CHDataStructures
- @interface doesn't work like Java's interfaces - it defines the instance variables and methods of a single class.
- You need header files. C is to blame for this. This pretty much sucks, as maintaining the things is an unnecessary pain.
- There is no concept of a "package". The closest thing is a framework, but these should not be used as Java's packages (i.e. don't create them just to organize your classes).
- Instead of "new Class()", say [[Class alloc] init]. Think of "alloc" like the new operator and init as the constructor.
- id's are generic object pointers, like references of type Object in Java.
- The base class is NSObject. Inheritance from NSObject is not automatic and must be explicitly specified.
Another conceptual difference is the behavior when calling methods (sending messages) on null objects (to nil).
Java
MyClass myObject = null;
myObject.doSomething(); <-- results in a NullPointerException
Obj-C
id myObject = nil;
[myObject doSomething]; <-- is valid
Here is a very good SO question about that behavior.