今天不经意一看,项目中有上千个警告了,虽然没有强迫症,但是看着也是觉得不舒服,刚好手头上的活不多,干脆就清理一下,记录一下过程。
消除警告
在清理之前,在网上查找资料发现有几种通用的方式消除警告。
- (void)addTapAction:(SEL)tapAction target:(id)target NS_DEPRECATED_IOS(2_0, 4_0);
- (void)addTapAction:(SEL)tapAction target:(id)target __attribute((deprecated("这个接口已经废弃")));
#pragma clang diagnostic push #pragma clang diagnostic ignored"-Wunused-variable" //这里是会报警告的代码 #pragma clang diagnostic pop
inhibit_all_warnings!
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"