static const in Obj-C

const T and T const are identical.

however: char const* is a pointer to a constant char (array), while char* const is a constant pointer to a mutable char (array).

NSString * const kPolygonNumberOfSides = @”…”; // const pointer
NSString const * kPolygonNumberOfSides = @”…”; // pointer to const

The first is a constant pointer to an NSString object, while the second is a pointer to a constant NSString object.

Don’t use const with Objective-C objects, they weren’t really designed to use it. NSString objects (among many others) are already immutable by default by virtue of their design, so making them const is useless.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.