Just stumbled upon the exact same static NSString declaration. I wondered how exactly this static magic works, so I read a little. I will only begin to consider the static part of your question.
According to K & R, each variable in C has two main attributes: type (for example, float) and storage class (auto, register, static, external, typedef).
The static storage class has two different effects, depending on whether it is used:
- inside a code block (for example, inside a function),
- outside all blocks (at the same level as the function).
A variable inside a block that does not have a declared storage class is considered automatic (i.e. local) by default. It will be deleted as soon as the block exits. When you declare an automatic variable static, it retains the value on exit. This value will still be present when the code block is called again.
Global variables (declared at the same level as the function) are always static. An explicit declaration of a global variable (or function) static limits the scope to only one source file. It will not be available, and it will not conflict with other source files. This is called intercom .
If you want to know more, read the internal and external links in C.
ksm
source share