Reputation: 113
I would like to know how to access the downloaded content from my server in Newsstand app. I have successfully downloaded the zip file which has all the useful assets for my app in the Caches Directory by using the NKAssetDownload. I know we can unzip the folder using ZipArchive. But to do that I am unable to find a way to access the path of the downloaded zip file.
Currently the path is:
simulator -> Applications -> my_app_id -> Library -> Caches -> Newsstand -> (some folder with Hexadecimal name) -> magazine.zip
magazine.zip is my downloaded file. the problem is with this Hexadecimal folder name.
Now I need help with any bit of code which can unzip this file and use the image.png in the unzipped folder in my imageView.
This is the code I have used:
NKLibrary *library = [NKLibrary sharedLibrary];
NKIssue *firstIssue = [library issueWithName:@"First Issue"];
firstIssue = [library addIssueWithName:@"First Issue" date:[NSDate date]];
NSURLRequest *urlReq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"location of my zip file"]];
NKAssetDownload *asset = [firstIssue addAssetWithRequest:urlReq];
[asset downloadWithDelegate:self];
Upvotes: 1
Views: 885
Reputation: 50109
the NKAssetDownload
takes a delegate, just like NSURLConnection does.
You should implement the NSURLConnectionDownloadDelegate
protocol and in the method - (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL
you get passed the url to the zip
Upvotes: 1