#pragma处理警告

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1e9421}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; min-height: 21.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c81b13}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3c828b}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c42275}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px 'PingFang SC'; color: #1e9421}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1e9421; min-height: 21.0px}p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3e1e81}p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #822d0f}p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1337ff}span.s1 {font-variant-ligatures: no-common-ligatures}span.s2 {font: 18.0px 'PingFang SC'; font-variant-ligatures: no-common-ligatures}span.s3 {font-variant-ligatures: no-common-ligatures; color: #822d0f}span.s4 {font-variant-ligatures: no-common-ligatures; color: #c42275}span.s5 {font-variant-ligatures: no-common-ligatures; color: #000000}span.s6 {font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures}span.s7 {font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #000000}span.s8 {font-variant-ligatures: no-common-ligatures; color: #c81b13}span.s9 {font-variant-ligatures: no-common-ligatures; color: #6122ae}span.s10 {font-variant-ligatures: no-common-ligatures; color: #3e1e81}span.s11 {font-variant-ligatures: no-common-ligatures; color: #1e9421}span.s12 {font-variant-ligatures: no-common-ligatures; color: #1337ff}

//
//  ViewController.m
//  pragma
//
//  Created by Code_Hou on 2017/3/30.
//  Copyright © 2017年 侯森魁. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

/*
 #pragma 在本质上是声明,常用的功能就是注释,尤其是给Code分段注释;然而它还有另外一个强大的功能是处理编译器警告.
 
 clang diagnostic 是#pragma 第一个常用命令:
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-相关命令"
   //自己的代码
 #pragma clang pop
 */
- (void)viewDidLoad {
    [super viewDidLoad];
    //取消方法启用的警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"1" message:@"2" delegate:nil cancelButtonTitle:@"3" otherButtonTitles:@"4", nil];
   [alert show];
#pragma clang diagnostic pop
    
    //取消不兼容指针类型警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
    //
#pragma clang diagnostic pop
    
    
    //取消循环引用的警告
    // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle.
#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 pop
    
    // Do any additional setup after loading the view, typically from a nib.
}

/*
 #pargma 用法详情:
 
 http://nshipster.cn/pragma/
 http://nshipster.com/clang-diagnostics/
 http://fuckingclangwarnings.com/
 http://clang.llvm.org/docs/UsersManual.[html](http://www.2cto.com/kf/qianduan/css/)#diagnostics_pragmas
 
 
 */

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

你可能感兴趣的:(#pragma处理警告)