- 宏定義(執(zhí)行原理就是直接查找替換)
- 被代表的部分多行時可使用\號連接
- #define PI 3.1415926
- 帶參宏定義:
- #define pingFang(a) a*a
- #define SingleH(name) +(instancetype)share##name;
- # undef 宏名稱
- 文件導入
- #include 直接插入,不判斷是否已存在
- #import 自動判斷是否已引入過,避免重復導入
- 條件編譯
- #ifdef , #ifndef , #else , #endif
- #if , #elif , #else , #endif
#ifdef __OBJC__
//只在OC文件中使用宏定義中的內(nèi)容
#endif
-------------------------------------------
//如果已經(jīng)包含了CoreImage.h文件
#if __has_include(<CoreImage/CoreImage.h>)
#import <CoreImage/CoreImage.h>
#endif
-------------------------------------------
#ifdef DEBUG
//調(diào)試階段
#define DebugLog(...) NSLog(__VA_ARGS__);
#define DebugMethod NSLog(@"%s",__func__);
#else
//發(fā)布階段
#define DebugLog(...)
#define DebugMethod
#endif
-------------------------------------------
//在代碼中打標記(-表示是否帶分割線)
#pragma mark - 隨機顏色創(chuàng)建
#pragma mark 隨機顏色創(chuàng)建
#warning xxxx
#error xxxxx
--------------------------------------------
#if __has_feature(objc_arc)
//所在文件使用ARC
#else
//所在文件使用MRC
#endif
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者