大佬教程收集整理的这篇文章主要介绍了如何取消AFdownloadrequest操作并且不保留以前的进度(删除临时文件)iOS,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
设置operation.deleteTempFiLeonCancel = YES;也没有帮助
operation.tempPath is returning null (not able to delete temporary filE)
我使用以下代码
NSURLrequest *request = [NSURLrequest requestWithURL:[NSURL URLWithString:model.downloadUrl]]; operation = [[AFDownloadrequestOperation alloc] initWithrequest:request targetPath:path shouldResume:YES]; operation.deleteTempFiLeonCancel = YES; // download operation progressive block [operation setProgressiveDownloadProgressBlock:^(AFDownloadrequestOperation *operation,NSInteger bytesRead,long long @R_282_10586@lBytesRead,long long @R_282_10586@lBytesExpected,long long @R_282_10586@lBytesReadForFile,long long @R_282_10586@lBytesExpectedToReadForFilE) { // calculate current download progress } }]; // download operation completion block [operation setCompletionBlockWithsuccess:^(AFhttprequestOperation *operation,id responSEObject) { } failure:^(AFhttprequestOperation *operation,NSError *error) { // operation Failed }]; [operation start];
如果在中间取消下载然后再次启动,我想从零开始下载.我使用的是iOS 7
在此行之后,您可以检查是否实际创建了tempPath
operation = [[AFDownloadrequestOperation alloc] initWithrequest:request targetPath:path shouldResume:YES]; NSLog("%@",operation.tempPath);
然后将该路径添加到字典中
NSString *tempPath = _operation.tempPath; [self.tempPathDict setObject:tempPath forKey:your_key];
NSString *tempPath = [self.tempPathDict objectForKey:your_key]; // Cancel the operation you want [operation cancel]; // Remove the tempFile NSError *error = [[NSError alloc] init]; [[NSFileManager defaultManager] removeItemAtPath:tempPath error:&error]; // And last remove the path from the Dictionary [self.tempPathDict removeObjectForKey:your_key];
以上是大佬教程为你收集整理的如何取消AFdownloadrequest操作并且不保留以前的进度(删除临时文件)iOS全部内容,希望文章能够帮你解决如何取消AFdownloadrequest操作并且不保留以前的进度(删除临时文件)iOS所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。