In this article, I won't treat in depth how to migrate from Java to Objective-C, but if you are going to do it, it would be helpful to you reading this stuff that simplify the understanding of the new language.
Let's start.
The main difference between Java and Objective-C is the memory management. Java developers may encounter some problems in approaching the concept of "memory release" and "memory leaks" because Java Garbage Collector hides to developers all the mechanisms regarding memory allocation and releasing.
Mastering memory management is, in my opinion, the most difficult thing to learn while starting to code in Objective-C. A general rule could be that for each "alloc" we must have a "release". We will see how and when at the right moment.
Some of the main concepts are similar and I will resume for you just a few common aspects of both languages.
All objects inherit from:
J - java.lang.Object
O - NSObject
Create a new object using:
J - MyObject obj = new MyObject();
O - MyObject *obj = [[MyObject alloc] init];
Use instance methods as follows:
J - myObject.doSomething(); (we say: call the method "doSomething" of myObject)
O- [myObject doSomething]; (we say: throw the message "doSomething" to myObject)
Get the string representation of an object:
J - myObject.toString();
O - [myObject description];
Difference between null (Java) and nil (Objective-C):
J - myObject = null; myObject.doSomething() will throw a NullPointerException
O - myObject = nil; [myObject doSomethin] will do NOTHING, the message doSomething is captured by none.
Manage user interactions on visual objects or capture events by:
J -
Listener: you need to implement all the methods defined in the Listener interface of the object.
O -
Delegate: you need to implement all the method defined in the Delegate class for an object.
Most of the name of user interface object follow those pattern:
J -
JSomething, like JButton, JTextField ...
O -
UISomething, like UIButton, UITextfield ...
Try/catch construct:
J- is heavily used and necessary to manage exception
O - rarely used. Main of the NSError are passed as pointers in the method that could throw an exception.
Getter/Setter methods:
J - By writing them for each instance variable
O - By using @property and @synthesize keywords
These are just a little part of the concepts but I hope it's a good start.
Happy coding!
(Thanks to my love for the patience!)