I am getting this error after the installing of pod AFNetworking 4.0.1 ,Below is the code:
- (NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(id)param progress:(NECBProgress)progress success:(NECBSucess)success failure:(NECBFailure)failure {
return [self.manager GET:URLString parameters:param progress:^(NSProgress *downloadProgress) {
if(progress) progress(@(1.0 * downloadProgress.completedUnitCount / downloadProgress.totalUnitCount));
} success:^(NSURLSessionDataTask *task, id data) {
@try {
LoggerI(@"GET-URLString:%@",URLString);
LoggerI(@"GET-Reponse:%@",[data jsonStringEncoded]);
if (success) success(task,data);
} @catch (NSException *exception) {
LoggerE(@"数据异常 HTTP:%@",URLString)
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
LoggerI(@"GET-URLString:%@",URLString);
LoggerI(@"GET-Error:%@",error.localizedDescription);
if (failure) failure(task,error);
}];
}
You call - (NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(nullable id)parameters headers:(nullable NSDictionary <NSString *, NSString *> *)headers progress:(nullable void (^)(NSProgress * _Nonnull))downloadProgress success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
without passing headers
. This is how you can fix it:
- (NSURLSessionDataTask *)GET:(NSString *)URLString parameters:(id)param progress:(NECBProgress)progress success:(NECBSucess)success failure:(NECBFailure)failure {
return [self.manager GET:URLString parameters:param headers:nil progress:^(NSProgress *downloadProgress) {
if(progress) progress(@(1.0 * downloadProgress.completedUnitCount / downloadProgress.totalUnitCount));
} success:^(NSURLSessionDataTask *task, id data) {
@try {
LoggerI(@"GET-URLString:%@",URLString);
LoggerI(@"GET-Reponse:%@",[data jsonStringEncoded]);
if (success) success(task,data);
} @catch (NSException *exception) {
LoggerE(@"数据异常 HTTP:%@",URLString)
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
LoggerI(@"GET-URLString:%@",URLString);
LoggerI(@"GET-Error:%@",error.localizedDescription);
if (failure) failure(task,error);
}];
}