Staticity is not needed because the constant is implicitly static.
No, it is not.
static when used in the scope of a file (that is, outside of any method or function) means that the variable is visible only inside this file.
extern means that the variable is defined in another file.
const means that the variable cannot be changed.
Consider the lines. Often you will have an implementation file (the name ends with .m) that defines some constant line pointer:
NSString *const SomeString = @"some string";
You might want to use the same constant from other files. If so, you can add an ad to the header (the name ends with an .h) file, which tells the compiler that the variable is defined elsewhere:
extern NSString *const SomeString;
and this will allow you to use SomeString in any file that imports the header file. On the other hand, you may decide that you definitely do not want the constant to be used outside the implementation file. In this case, you can declare it static (in the implementation file again):
static NSString *const SomeString = @"some string";
and this will prevent its use outside the file.
The call to NSString * const x actually declares a constant and immutable value at x. I cannot change the value, but I can change what x points to.
That's right, it declares the x pointer constant - you cannot change it. You also cannot change the value that it points to if it is really NSString , because the instance of NSString does not change.
This constant has an internal relationship, meaning that the value is determined immediately (presumably at compile time).
I'll take the fifth one on this - I donβt know exactly how the compiler deals with constant lines. I find it safe to use this as a mental model; the string will be defined anyway before your code ever uses it.