.pch

.pch文件

说明:
.pch 文件其实就是在编译前为每个类 import 头文件。每次编译只会再次编译有变动的文件,如果 .pch 文件变动,那么所有的文件有变动,都得重新编译,这样会影响编译时间。


// 偏好设置
#define CH_USERDEFAULT [NSUserDefaults standardUserDefaults]
// 整个屏幕的宽高
#define CH_SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define CH_SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
// 实际应用的宽高(除去状态栏)
#define CH_APP_WIDTH ([UIScreen mainScreen].applicationFrame.size.width)
#define CH_APP_HEIGHT ([UIScreen mainScreen].applicationFrame.size.height)
// 状态栏和导航栏高度
#define CH_STATUS_BAR_HEIGHT 20
#define CH_NAVIGATION_BAR_HEIGHT 44   

// 系统版本 "4.0"     
// 因为转 CGFloat 有精度误差,所以如果想要支持 iOS 7 及以上,应该使用 CH_SYSTEM_VERSION > 6.x 来判断,而不应该使用 >=
#define CH_SYSTEM_VERSION [[UIDevice currentDevice] systemVersion].floatValue
// App delegate
#define CH_APP_DELEGATE ((AppDelegate *)[[UIApplication sharedApplication] delegate])        

// 沙盒路径
#define CH_DOCUMENT_PATH [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define CH_TEMP_PATH NSTemporaryDirectory()
#define CH_LIB_PATH [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0] 

// 设备类型 iPhone  iPad  TV
#define CH_IS_IPHONE [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone
#define CH_IS_IPAD [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad
#define CH_IS_TV [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomTV   

// GCD
#define CH_BACK_DEFAULT_BLOCK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define CH_MAIN_BLOCK(block) dispatch_async(dispatch_get_main_queue(),block)   
  
// 控制打印   
#ifdef DEBUG
#define CHLog(fmt, ...) NSLog((@"\nFUNC: %s ---- [Line %d] \n" fmt),__func__, __LINE__, ##__VA_ARGS__)
#else
#define CHLog(fmt, ...)
#endif

// 单例声明
#define CH_SINGLETON_H(name) + (id)default##name;
// 单例实现
#define CH_SINGLETON_M(name) \
+ (id) allocWithZone:(struct _NSZone *)zone { \
static id s = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
s = [[super allocWithZone:NULL] init]; \
}); \
return s; \
} \
- (id) copyWithZone:(NSZone *)zone { \
return self; \
} \
- (id) mutableCopyWithZone:(NSZone *)zone { \
return self; \
} \
+ (id) default##name { \
return [self allocWithZone:NULL]; \
} \

感谢:
Xcode6及之后为什么要去掉PCH文件
.pch 文件全局配置

转载于:https://www.cnblogs.com/imock/p/6540442.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值