美文网首页
iOS消除警告

iOS消除警告

作者: 斑驳的流年无法释怀 | 来源:发表于2017-01-12 08:13 被阅读88次

    使用格式

     #pragma clang diagnostic push
       #pragma clang diagnostic ignored "-相关命令"
       # //需要操作的代码
    #pragma clang diagnostic pop
    
    • 忽略弃用的警告
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wdeprecated-declarations"
        UIAlertView *alertViewTmp = [[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:nil cancelButtonTitle:@"" otherButtonTitles:@"", nil];
        [alertViewTmp show];
    #pragma clang diagnostic pop
    
    • 忽略不兼容指针类型
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wincompatible-pointer-types"
        //
    #pragma clang diagnostic pop
    
    • 循环引用
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Warc-retain-cycles"
    //    self.completionBlock = ^ {
    //        ...
    //    };
    #pragma clang diagnostic pop
    
    • 未使用变量
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wunused-variable"
        int a;
    #pragma clang diagnostic pop
    
    • 未使用default
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wcovered-switch-default"
    //    switch (style) {
    //        case UITableViewCellStyleDefault:
    //        default:
    //            return;
    //    }
    #pragma clang diagnostic pop
    

    参考 Clang's source code

    相关文章

      网友评论

          本文标题:iOS消除警告

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