1

I m working on a app with the NewsstandKit.frame work. There was the NKAssetDownload request:

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

And the way I stop/pause the downloading it to cancel the connect:

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

And then there becomes the question,when I run the app again, there will show the wrong information about:

-[NKAssetDownload cover]: unrecognized selector sent to instance 0x6c69fc0 2012-10-26 15:49:39.257 MyMagazineDemoV0.0.1[3872:fb03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NKAssetDownload cover]: 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

I duno wut does it mean,cuz I can not find the method called"cover" in NKAssetDownload. Could anybody help me?:)

1 Answers1

0

The correct procedure to start the download is as follows:

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

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

When removing an issue, you should also remove the issue from Newsstand library:

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

In addition to this u have to implement the NSURLConnectionDownloadDelegate methods

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

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

Try this. This works without error.

Revanth
  • 113
  • 12