For pointers to things like NSString, the const needs to be after the *. Reading the declaration from right to left, static const NSString *foo means "foo is a pointer to an NSString that is constant". i.e. the NSString data is constant, but NSStrings are already immutable. That means the pointer foo can be reassigned to some other string.
What we want is static NSString * const foo which means "foo is a constant, unchangeable pointer to an NSString".
This next point is debatable, but for consistency, I suggest always putting the const after the type for primitive types too. Technically, const is supposed to modify what precedes it.
For pointers to things like NSString, the
const
needs to be after the*
. Reading the declaration from right to left,static const NSString *foo
means "foo is a pointer to an NSString that is constant". i.e. the NSString data is constant, but NSStrings are already immutable. That means the pointerfoo
can be reassigned to some other string.What we want is
static NSString * const foo
which means "foo is a constant, unchangeable pointer to an NSString".This next point is debatable, but for consistency, I suggest always putting the
const
after the type for primitive types too. Technically,const
is supposed to modify what precedes it.Reference: http://stackoverflow.com/questions/7526152/easy-rule-to-read-complicated-const-declarations