The * position relative to the variable name does not matter to the compiler. Some people prefer to put * with a variable, though, because it avoids confusion when declaring multiple variables:
char* a, b;
However, you always reference objects in Objective-C through pointers, so never do something like the first line below:
NSString *a, b;
On the other hand, the position of const really matters:
int * const a;
Now const does not make much sense regarding objects. First, NSString represents an immutable string, so declaring one const does not add much. For the other, as a rule, it modifies the object in Objective-C by sending a message, rather than directly changing the ivars object, and I don't think the compiler will prevent changes made through messages. Therefore, a const pointer makes sense, a pointer to a const object, not so much:
NSString * const BLANK_SPACE = @" ";
Caleb
source share