When to use # define, when to use const?
Effective Objective C ITEM4 says this:
Prefer Typed Constants to preprocessor #define
1. Avoid # define. Because there is no type information, and may be redefined
2. defined as a static const in M files (in fact this process is the same as # define)
3. For global constants, it should be stated in the header file, defined in the relevant m file, that the class name prefixed with the response
As in. h,
extern const Nstimerinterval Classanimationduration;
In. M,
Const Nstimerinterval? classanimationduration=0.3;
(As with various Notificaiton in uiapplication)
?
=====================
Note the const position, which modifies the const key before the keyword, such as
Static NSString * Const CONSTANT; Refers to the const pointer to an NSString
=====================
iOS Development Summary (A0)-#define and const