Domanda

I got the AFNetworking version available on cocoapods (2.0.0-RC2) and in the AFURLSessionManager.m file the method do not invoke the failure block on the main thread in opposite of the success block. Is that on purpose or it is an error with the library?

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

}
È stato utile?

Soluzione

It seems that it was a bug, as in 2.0 final release the blocks are called on a different way, as you can see in the master branch.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top