The role of 1.const:
Const is used only to modify the right variable (basic data variable p, pointer variable *p). For example NSString *const sialertviewwilldismissnotification;
Const-Modified variables are read-only
The role of 2.static:
- To modify a local variable:
1. Extend the life cycle of a local variable, and the program ends before it is destroyed.
2. Local variables generate only one copy of memory and are initialized only once.
3. Change the scope of the local variable.
- modifying global variables
1. Can only be accessed in this file, modify the scope of global variables, the life cycle will not change
2. Avoid repeating the definition of global variables
3..PCH generated global variables are one copy of each file, so the modification of the file's global variables can not be modified across files
The role of extern
- A value that is used to get global variables (including global static variables) and cannot be used to define variables
- extern works: First in the current file to find there are no global variables, not found, will go to other files to find.
(for example, another. h or. m file declares a global variable that you want to use on the current page)
The other interface Appdelegate declares a
NSString *const kdevicetokenstring = @ "kdevicetokenstring";
Current interface
extern nsstring *const kdevicetokenstring;
Learn the link and thank the author for sharing
Original link: http://www.jianshu.com/p/9fd82a6d016b
Usage of extern,static,const in OC