美文网首页
iOS开发中的常用define定义

iOS开发中的常用define定义

作者: 优雅的步伐 | 来源:发表于2018-10-12 15:48 被阅读0次

    iOS开发中的常用define定义

    //获取iphone的基本信息:

    #define ScreenHeight [[UIScreen mainScreen] bounds].size.height

    #define ScreenWidth [[UIScreen mainScreen] bounds].size.width

    #define IOS7_OR_LATER ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)

    #define IOS8_OR_LATER ([[[UIDevice currentDevice] systemVersion] doubleValue]>=8.0)

    #define IOS9_OR_LATER ([[[UIDevice currentDevice] systemVersion] doubleValue]>=9.0)

    #define IOS_VERSION_10 (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_9_x_Max)?(YES):(NO)

    #define DeviceId [UIDevice currentDevice].identifierForVendor.UUIDString

    // weakself 宏

    #define WEAKSELF    __weak __typeof(&*self) weakSelf = self;

    //接口定义

    #define HTTP_ORDER_LIST   @"order/list"

    //block相关宏

    #define VDBlockSafeRun(block, ...) block ? block(__VA_ARGS__) : nil

    //测试时使用log打印信息,发布时删除打印

    #ifndef __OPTIMIZE__//DEBUG

    # define NSLog(...) NSLog(__VA_ARGS__)

    #else

    # define NSLog(...)

    #endif

    注:

    #ifdef是条件编译语句,在编译阶段执行,后面跟一个宏的名称,如果这个宏已经定义了,就编译对应的语句

    #ifndef是条件编译语句,在编译阶段执行,后面跟一个宏的名称,如果这个宏没有定义,就编译对应的语句

    相关文章

      网友评论

          本文标题:iOS开发中的常用define定义

          本文链接:https://www.haomeiwen.com/subject/islgaftx.html