AFNetworking 2.0.0-RC2不在主线程上调用故障块

时间:2013-09-11 18:32:44

标签: afnetworking afnetworking-2

我在cocoapods(2.0.0-RC2)上获得了AFNetworking版本,在AFURLSessionManager.m文件中,该方法不会在成功块对面的主线程上调用失败块。这是故意的还是库的错误?

- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
                                  success:(void (^)(NSURLResponse *response, id responseObject))success
                                  failure:(void (^)(NSError *error))failure
{
    NSURLSessionDataTask *task = [self.session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    if (error) {
        if (failure) {
            failure(error);
        }
    } else {
....
        id responseObject = [self.responseSerializer responseObjectForResponse:response data:data error:&serializationError];

            dispatch_async(dispatch_get_main_queue(), ^(void) {
                if (serializationError) {
                    if (failure) {
                        failure(serializationError);
                    }
                } else {
                    if (success) {
                        success(response, responseObject);
                    }
                }

}

1 个答案:

答案 0 :(得分:1)

似乎这是一个错误,因为在2.0最终版本中,块以不同的方式被调用,正如您在the master branch中看到的那样。