1. commend +n 新建一个pch文件,命名为工程名,如:QXD.pch (在Xcode6之前该文件自动生成)
2. 在build Settings 中搜索 Prefix Header
3. 在这一行填写 刚刚所新建的pch文件路径 项目名/项目名.pch
4. 宏定义都可以写在这个文件中,或者需要多处用到的类可以引入该文件(省去重复引入的操作)
5. 常用的宏定义
#define NSLog(...) NSLog(__VA_ARGS__)//日志输出
#define WIDTH [[UIScreen mainScreen]bounds].size.width//屏幕宽
#define HEIGHT [[UIScreen mainScreen]bounds].size.height//屏幕宽
#define LOADIMAGE(file,type) [UIImage imageWithContentsOfFile: [[NSBundle mainBundle]pathForResource:file ofType:type]]//加载本地图片的宏
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]//沙河路径
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]//沙河路径
#define getCurentTime [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]//获取系统时间戳
#define kNotficationDownloadProgressChanged @"kNotficationDownloadProgressChanged" //下载进度变化
#define kNotificationPauseDownload @"kNotificationPauseDownload" //暂停下载
#define kNotificationStartDownload @"kNotificationStartDownload" //开始下载
#define kNotificationDownloadSuccess @"kNotificationDownloadSuccess" //下载成功
#define kNotificationDownloadFailed @"kNotificationDownloadFailed" // 下载失败