1

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];
Revanth
  • 113
  • 12

1 Answers1

1

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

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • bonus: for unzipping look at https://github.com/flyingdolphinstudio/Objective-Zip or my DDMinizip lib – Daij-Djan Dec 28 '12 at 12:33
  • :) Great I have managed unzipping with the help of ZipArchive... And one more doubt I have is that moving of the unzipped issue into the Documents folder is fair or a bad practice...? Thanks for your response – Revanth Dec 29 '12 at 07:09
  • 2
    It is not okay to move unzipped issue into "Documents" folder, which according to Apple should be for content that can not be restored from cloud (app generated content). Apple has already rejected apps of so many developers I know only due to this reason. – msk Dec 29 '12 at 11:51
  • @MSK So how's about moving the Unzip content to the Library folder of the app rather than documents. Will that work on approval or any other path you would recommend ? – Ajay Sharma Apr 15 '13 at 11:46