29,027
社区成员
发帖
与我相关
我的任务
分享
NSURLSessionDownloadTask *downloadTask = [self.sessionManager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
return [NSURL fileURLWithPath:RellayPath(_userInfor.UserID)];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error)
{
if (![error.userInfo[@"NSLocalizedDescription"] isEqualToString:@"cancelled"])
{
ZJLog(@"%@", error.userInfo[@"NSLocalizedDescription"]);
if (![error.userInfo[@"NSLocalizedDescription"] isEqualToString:@"The request timed out."])
{
}
count++;
float progress = (float)(count) / downCount * 100;
ZJLog(@"%f", progress);
if (progress < 99)
{
self.downProgressLabel.text = [NSString stringWithFormat:@"%2.0f%%", progress];
}
else
{
self.downProgressLabel.text = @"99%";
}
if (count == downCount)
{
self.downProgressLabel.text = @"100%";
[self changeStatus:Completion];
}
}
}];
[downloadTask resume];
if ([error.userInfo[@"NSLocalizedDescription"] isEqualToString:@"The request timed out."])
{
ZJLog(@"请求超时的url:%@", error.userInfo[@"NSErrorFailingURLKey"]);
[self downloadTaskWithUrl:error.userInfo[@"NSErrorFailingURLKey"]];
}