使用格式大致如下:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-相關(guān)命令"
//需要操作的代碼
#pragma clang diagnostic pop
栗子1:忽略棄用的警告??
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"" message:@"" delegate:nil cancelButtonTitle:@"" otherButtonTitles:@"", nil];
[alertView show];
//方法棄用告警
#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
栗子2:忽略不兼容指針類型??
// 不兼容指針類型
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
//
#pragma clang diagnostic pop
栗子3:循環(huán)引用??
break the retain cycle.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
// self.completionBlock = ^ {
// ...
// };
#pragma clang diagnostic pop
栗子4:未使用變量 ??
// 未使用變量
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
int a;
#pragma clang diagnostic pop
栗子5:未使用default ??
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcovered-switch-default"
// switch (style) {
// case UITableViewCellStyleDefault:
// case UITableViewCellStyleValue1:
// case UITableViewCellStyleValue2:
// case UITableViewCellStyleSubtitle:
// // ...
// default:
// return;
// }
#pragma clang diagnostic pop
http://blog.csdn.net/zww1984774346/article/details/53409033
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者