取消NKAssetDownload时,应用程序无法启动

时间:2012-10-26 07:57:55

标签: ios5 newsstand-kit

我正在使用NewsstandKit.frame工作的应用程序。 有NKAssetDownload请求:

    NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:5.0];
    _assetDownload = [self.issue addAssetWithRequest:request];
   [_assetDownload downloadWithDelegate:self];

我停止/暂停下载以取消连接的方式:

    NSURLConnection *con = [[self.issue.downloadingAssets objectAtIndex:0] downloadWithDelegate:self];
    [con cancel];

然后就会出现问题,当我再次运行应用程序时,会显示错误的信息:

- [NKAssetDownload cover]:无法识别的选择器发送到实例0x6c69fc0 2012-10-26 15:49:39.257 MyMagazineDemoV0.0.1 [3872:fb03] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [NKAssetDownload cover]:无法识别的选择器发送到实例0x6c69fc0' * 第一次抛出调用堆栈: (0x18b1022 0x1a42cd6 0x18b2cbd 0x1817ed0 0x1817cb2 0x10405 0x1018d 0x12f0a 0x127f8 0x3a2a 0x3d999b 0x338401 0x338a46 0x254e 0x310386 0x311274 0x320183 0x320c38 0x314634 0x179bef5 0x1885195 0x17e9ff2 0x17e88da 0x17e7d84 0x17e7c9b 0x310c65 0x312626 0x2292 0x2205) 终止调用抛出异常

我duno wut是否意味着,因为我无法在NKAssetDownload中找到名为“cover”的方法。 有人可以帮帮我吗?:)

1 个答案:

答案 0 :(得分:0)

开始下载的正确步骤如下:

currentIssue = [library addIssueWithName:issueName date:issueDate];

NSURLRequest * urlReq = [NSURLRequest requestWithURL:[NSURL URLWithString:file_Url]]; NKAssetDownload * asset = [currentIssue addAssetWithRequest:urlReq]; [asset downloadWithDelegate:self];

删除问题时,您还应该从报亭图库中删除该问题:

NKIssue *issueToRemove = [[NKLibrary sharedLibrary] issueWithName:issueName];
if (issueToRemove) {
    [[NKLibrary sharedLibrary] removeIssue:issueToRemove];
}

除此之外,你必须实现NSURLConnectionDownloadDelegate方法

  • (void)connection:(NSURLConnection *)connection didWriteData :( long long)bytesWritten totalBytesWritten :( long long)totalBytesWritten expectedTotalBytes :( long long)expectedTotalBytes

  • (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL

试试这个。这没有错误。