It's a good question.
There are some types that are not derived from NSObject, these types are called "Primitive Types." Some examples of these types are
Sooooo basically any type that is not derived from the NSObject class is a Primitive type and does not require a "*".
Now I bet you are wondering how do I figure out if it's a primitive type or not.
- An easy way is to look at the color of the syntax in xCode, is it deep blue or a sky blue? Deep blue = primitive type, but this is not entirely reliable as the standards for coloring syntax can fluctuate or change.
- You can option-click on the object after you have typed it in xCode, click the little book in the upper right hand corner, when the class reference viewer comes up, look and see if it inherits from NSObject. If it doesn't it's Primitive and you don't need a "*".
There are some alternatives to using the primitive type int
, such as the reference type NSInteger,
some nice baked in functionality of distinguishing between 32 bit and 64
bit, but not all primitive types have an alternative reference type in Objective C.Just for fun:
In .Net they have primitive types too(I believe they call them value types
), kinda. The compiler recognizes traditional primitive types and therefore lets you use the syntaxint i = 5;
But despite the compiler letting you do this, this type still maps back to System.Int32. All things in .Net are mapped back to System.Object. Everything is a reference type, but .Net lets you keep the traditional syntax instead of writing:System.Int32 i = new System.Int32(5);UPDATE:
Enumerations types also do not use a * (star) and they have the sky blue coloration that may make you think you need a *.