取消网络请求
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSURLSessionDataTask *task = [manager GET:@"url地址"parameters:@"入参"progress:^(NSProgress *_Nonnull downloadProgress) {
//数据请求进度
} success:^(NSURLSessionDataTask *_Nonnull task,id _Nullable responseObject) {
//请求成功
} failure:^(NSURLSessionDataTask *_Nullable task,NSError *_Nonnull error) {
//请求失败
}];
//取消单个网络请求
[task cancel];
//取消所有的网络请求
[manager.operationQueue cancelAllOperations];
网络超时
[manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
manager.requestSerializer.timeoutInterval = 10.f;
[manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
网友评论