'AFHTTPSessionManager' 没有可见的@interface 声明了选择器 'GET:parameters:progress:success:failure:'

No visible @interface for 'AFHTTPSessionManager' declares the selector 'GET:parameters:progress:success:failure:'

我在安装 pod AFNetworking 4.0.1 后收到此错误 ,下面是代码:

- (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);
    }];
    
}

您呼叫 - (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 而未通过 headers。您可以通过以下方式修复它:

- (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);
    }];
    
}