AFNetworking,使用共享AFHttpSessionManager,待处理请求在更新请求完成时被取消

时间:2016-09-23 07:37:39

标签: afnetworking afnetworking-3

我在单例模式下使用AFHTTPSessionManager,并启动多个请求,如:

[MyAPI testSlow]; 
[MyAPI testQuick];

MyAPI定义:

+(void)testSlow { 
AFHTTPSessionManager *manager = [BPNetworkManager sharedManager]; // Get Manager Singleton 
NSString *urlString = [BPCommonUtils getUrlByPath:@"/api/test/testSlow"];
[manager GET:urlString parameters:nil success: ^(NSURLSessionTask *operation, id responseObject) { 
   NSLog(@"slowSuccess"); 
} failure:^(NSURLSessionTask *operation, NSError *error){ 
   NSLog(@"slowFail"); 
}];

}

+(void)testQuick { 
AFHTTPSessionManager *manager = [BPNetworkManager sharedManager]; 
NSString *urlString = [BPCommonUtils getUrlByPath:@"/api/test/testQuick"]; 
[manager GET:urlString parameters:nil success: ^(NSURLSessionTask *operation, id responseObject) { 
NSLog(@"quickSuccess"); 
} failure:^(NSURLSessionTask *operation, NSError *error){ 
NSLog(@"quickFail"); 
}]; 
}

当“快速任务”成功返回时,“慢速任务”立即失败,消息信息失败: @“NSURLErrorDomain” - 代码:18446744073709550617

@“NSLocalizedDescription”:@“已取消”

我该如何解决?谢谢!

0 个答案:

没有答案