뉴스 스탠드 앱을 만들고 있는데 다운로드 할 문제마다 많은 다운로드 자산이 있습니다. "issues"는 서버에서 요청한 NSArray *입니다. 나는 MyDownloader 클래스에서이 같은 모든 자산을 반복하여 다운로드를 시작 : 나는 관련하여 나중에 사용하기 위해 localFilepath를 저장하고있어newsstand : 버려진 자산 다운로드가 여전히 다운로드 중입니다.
for (int i=0; i< issues.count; i++)
MyIssue *currentIssue = [issues objectAtIndex:i];
NSString *filename = [currentIssue.remotePath lastPathComponent];
NSString *localFilepath = [cache.cachePath stringByAppendingString:filename];
//skip downloaded file
if ([[NSFileManager defaultManager] fileExistsAtPath:localFilepath]) {
continue;
}
NSURL *downloadURL = [NSURL URLWithString:currentIssue.remotePath];
// let's create a request and the NKAssetDownload object
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:downloadURL];
NKAssetDownload *assetDownload = [nkIssue addAssetWithRequest:req];
[assetDownload setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:
localFilepath, @"Filepath",
nil]];
// let's start download
[assetDownload downloadWithDelegate:self];
}
: didFinishDownloading : DESTINATIONURL 방법.
한 가지를 제외하고 모든 것이 잘 작동합니다. didFinishLaunchingWithOptions : : 방법
NKLibrary *nkLib = [NKLibrary sharedLibrary];
for(NKAssetDownload *asset in [nkLib downloadingAssets]) {
NSLog(@"Asset to download: %@",asset);
MyDownloader *downloader = [MyDownloader sharedDownloader];
[asset downloadWithDelegate:downloader];
}
이것은 또한 잘 작동 여기에 내가 응용 프로그램에 넣어 코드입니다. didFinishLaunchingWithOptions이 :, 나는이 같은 로그 메시지를 얻을 : 나는 모든 대기중인 다운로드를 취소 할 필요가있을 때, 나는 응용 프로그램에서 이전 코드를 주석
NewsstandKit: cleaning up abandoned asset downloads: (
"<NKAssetDownload: 0xa17ffe0> -> {identifier: '98E98868-0DD2-45FF-90B8-7CF80E02A952/B11F6C43-86CC-4434-ABC1-F4450FF163CF' request: <NSMutableURLRequest http://servername/serverpath/file.zip> downloading: NO}"
그리고 나는 모든 다운로드가 취소됩니다 기대합니다. 그러나 응용 프로그램의 Library/Cache 디렉토리를 보면 "bgdl-2896-"로 시작하는 파일 이름으로 많은 파일을 다운로드하는 것을 볼 수 있습니다. 그래서 그들은 취소되지 않고 NewsstandKit에 의해 다운로드됩니다. connection : didFinishDownloading : destinationURL 메서드도 호출되지 않습니다. 문제는 자산이 인터넷 트래픽과 기기의 저장 공간을 소모한다는 것입니다.
더 이상 필요하지 않은 저작물 다운로드를 취소하려면 어떻게해야합니까?
문제는 자산 수량에 관한 것이 아니라 원하는 경우에도 취소되지 않는 문제입니다. – VasVF