我在我的应用程序中遇到问题,NSURLSessionDownloadTask
我使用代码创建了数百个下载任务:
NSURLSessionDownloadTask * task = [_urlSession downloadTaskWithURL:downloadUrl];
NSLog(@"session: %@, download task %@ for url: '%@'",_urlSession, task, downloadUrl);
if (!task)
{
NSLog(@"ooops no task");
}else
{
}
在 xcode 控制台中,我有这样的消息:
2014-03-28 11:23:39.297 MYAPP[3838:60b] session: <__NSCFURLSession: 0x19471e70>, download task (null) for url: 'http://xxx.cloudfront.net/seminarcontent/nsm_photos_11_24d8505e-4ddd-4e9b-baef-a90d5e322702.jpg'
同样在组织者的控制台中,我看到了这条消息:
nsnetworkd[322] <Error>: __NSCFLocalDownloadFile: error 2 creating temp file: /private/var/mobile/Applications/MYAPPGUID-BD21-4C5A-8DB6-845D80BE75E3/Library/Caches/com.apple.nsnetworkd/CFNetworkDownload_R91Hqn.tmp
NSURLSession 之前创建的:
_urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration backgroundSessionConfiguration:sessionIdenttificator] delegate:self delegateQueue:nil];
所有网址都是有效的,只有当我在应用程序启动后开始下载时才会发生这种情况
请分享您对我的问题的想法。提前致谢。
更新:
我还添加了对缓存目录的检查,确保在我开始下载之前存在但没有任何改变
编辑
附加信息,我无法在模拟器中或在调试模式下的设备上重现该错误(启用断点)。