第一种解决方案
在下面代码中添加一下三句
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic pop
// 视频分类数据 - (void)getVideoDadaSource:(void (^)(NSArray *))successBlock { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; NSString *versi = @"1.0.0"; NSString *platform = @"i"; NSString *lastUrl = @"/video/index"; // NSString *token = @"SXlNak16RTNOV0UwTURSalkyRm1NVFEwWWpnMU5tWmpOelUxWWpGa1pUZGtaVEFKTVRnPVJ2a0c3QjJQ"; [dict setObject:platform forKey:@"p"]; [dict setObject:versi forKey:@"v"]; NSMutableArray *mdataArray = [NSMutableArray array]; //写在这个中间的代码,都不会被编译器提示-Wdeprecated-declarations类型的警告 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" // [dict setObject:token forKey:@"token"]; [[AFAppDotNetAPIClient sharedClient] GET:[NSString stringWithFormat:@"%@%@",BASE_URL,lastUrl] parameters:dict success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSArray *dataArray = [responseObject objectForKey:@"data"]; if ([responseObject isKindOfClass:[NSDictionary class]]) { for (NSDictionary *dic in dataArray) { _videoModel = [[VideoModel alloc]initWithDict:dic]; [mdataArray addObject:_videoModel]; } if(successBlock){ successBlock(mdataArray.copy); } } } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { }]; //写在这个中间的代码,都不会被编译器提示-Wdeprecated-declarations类型的警告 #pragma clang diagnostic pop }
第二种解决方案
第一步 找到要取消的警告类型
在相应的警告上右击->Reveal in Log
被选中的-Wdeprecated-declarations就是我们所要的警告类型了。
-W是前缀,这个前缀表示的是 打开这种类型的警告 如果我们是要关闭某种类型的警告的话, 要将 -W换成 -Wno-
第二步 设置
找到下图所示的Other Warning Flags,双击,添加-Wno-deprecated-declarations就可以了。