1

我正在使用 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 封面]:无法识别的选择器发送到实例 0x6c69fc0 2012-10-26 15:49:39.257 MyMagazineDemoV0.0.1[3872:fb03] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[NKAssetDownload 封面]: unrecognized selector sent to instance 0x6c69fc0' * First throw call stack: (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) terminate called throwing an exception

我不知道这是什么意思,因为我在 NKAssetDownload 中找不到名为“cover”的方法。有人可以帮助我吗?:)

4

1 回答 1

0

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

currentIssue = [图书馆 addIssueWithName:issueName date:issueDate];

NSURLRequest *urlReq = [NSURLRequest requestWithURL:[NSURL URLWithString:file_Url]]; NKAssetDownload *asset = [currentIssue addAssetWithRequest:urlReq]; [资产下载WithDelegate: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

尝试这个。这工作没有错误。

于 2013-06-11T06:37:34.187 回答