prefix.pch文件的一些简单使用

该文件可以引入一些全局通用的文件,这样就不用每次在文件中导入,也可以定义全局通用的变量或常量,如

//定义NSString常量
#define     ServiceName     @"cn.zmfc"
//定义颜色
#define BackgroudColor  [UIColor colorWithRed:232/255.0 green:235/255.0 blue:240/255.0 alpha:1.0]
//定义IOS系统版本等
#define   currentVersion        [[UIDevice currentDevice].systemVersion floatValue]
#define   isIOS8        (currentVersion >= 8.0)
#define   isIOS7        (!isIOS8 && currentVersion >= 7.0)
#define   isIOS6        (currentVersion <= 6.0)
//定义数组
#define  ScatterArray   @[@"mega",@"medium",@"small",@"person",@"other"];

如对于判断版本问题,可直接使用。如

if(isIOS8){
    //要做的事
}
原文地址:https://www.cnblogs.com/Apologize/p/4332545.html