When i read colleagues\' code in my team, i usually found there were two different types of definition for const NSString objects:
static NSString const *
I prefer static const NSString *var;
because static
and const
are qualifiers for the NSString pointer.
Only the pointer is const
not the NSString.
The NSString will be constant because it is not mutable but a const NSMutableString *s
will not make s mutable String become constant and so not modifiable. The pointer to the mutable String s will be constant and the compiler won't allow you to modify it.
Sorry for the inversion: Ken Thomases is right: int * const Var;
means the pointer is constant and cannot be changed, but the data it points to can be changed. const int * Var
means the data pointed to by Var cannot be changed.