美文网首页系统宏
常用系统宏定义

常用系统宏定义

作者: sunflower1518 | 来源:发表于2016-10-09 13:57 被阅读17次
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
    // iOS SDK 7.0 以后版本的处理
    #else
    // iOS SDK 7.0 之前版本的处理
    #endif
    
    #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
    // 如果选择(iOS Deployment Target)的最低支持版本在iOS7.0及以上才可以使用
    #endif
    
    #if TARGET_OS_IPHONE
    //iphone 程序
    #endif
    
    #if DEBUG
    //debug 模式
    #endif
    
    #if TARGET_IPHONE_SIMULATOR
    //模拟器运行
    //@"iRate could not open the ratings page because the App Store is not available on the iOS simulator";
    #endif
    
    #if !__has_feature(objc_arc)
    //非arc环境
    #error This class requires automatic reference counting
    #endif
    

    判断该ios系统 是否有某个类/方法

    //判断该ios系统 是否有某个类
    #if __IPHONE_OS_VERSION_MAX_ALLOWED > 80000
    // Weakly Linked判断
    if ([UIAlertController class]) {
        // 使用UIAlertController...
    } else {
        // 使用旧的方案...
    }
    #endif
    
    //也可以如下判断:
    Class class = NSClassFromString (@"UIAlertController");
    if (class) {
        // 使用UIAlertController...
    } else {
        // 使用旧的方案...
    }
    
    //判断是否相应某方法方法
    if ([UITableViewCell instancesRespondToSelector:@selector (setSeparatorInset:)]) {
        // ...
    } else {
        // ...
    }

    相关文章

      网友评论

        本文标题:常用系统宏定义

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