From Java to Objective-C (1)


> BOOL, YES, NO – boolean, true, false
In Java, the boolean type is boolean. In Objective-C, it is BOOL, which can be set to YES or NO.

> nil, NULL and null
nil is the equivalent of NULL for a pointer to an object. nil and NULL should not be interchangeable.
use nil to set and test Objective-C object references exactly as you would use null in Java.
NULL is C’s empty pointer constant and is used to set and test pointers.

> id
id is object type.

> +, –
an instance method is declared with a minus sign (-) prefix.
similar as instance method sign (+) defines a class method.

> namespace and source code
use #import and a prefix to identify the origin of a class, no package and namespace, eg. NS for Cocoa NSObject, CC for Cocos2D CCNode.
Objective-C uses .h files for headers, and .m files for the code; .mm files are used for Objective-C++.


About xlcwu

Self-employed (One-man Company), Developer/Chief Designer/Consultant, Embedded Linux/NAS/Storage/Platform/Devices, Xcode/Cocos2D/Cocoa/Objective-C, at Joe’s Lab – Newland ESP (TM).
This entry was posted in Programming and tagged , , . Bookmark the permalink.

One Response to From Java to Objective-C (1)

  1. Expand this post on
    Protocols, and Blocks on Objective C.
    ( I still cant get them )

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s