今天不经意一看,项目中有上千个警告了,虽然没有强迫症,但是看着也是觉得不舒服,刚好手头上的活不多,干脆就清理一下,记录一下过程。
消除警告
在清理之前,在网上查找资料发现有几种通用的方式消除警告。
no-
:#pragma clang diagnostic push #pragma clang diagnostic ignored"-Wunused-variable" //这里是会报警告的代码 #pragma clang diagnostic pop
注意:关于project和targets的选择,有些类型的警告只能在project中的build Settings中添加才有效,有些则是需要在target中添加才有效,例如Unused variable,如果项目中只有一个target,那么可以在project和target中都加上。
- (void)addTapAction:(SEL)tapAction target:(id)target NS_DEPRECATED_IOS(2_0, 4_0);
- (void)addTapAction:(SEL)tapAction target:(id)target __attribute((deprecated("这个接口已经废弃")));