0

I'm working on typical newsstand app and I have problem with unzipping downloaded file.

-(void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL {

// copy the file to the destination directory

NSURL *finalURL = [[self contentURL] URLByAppendingPathComponent:@"magazine.zip"]; ELog(@"Copying item from %@ to %@",destinationURL,finalURL);

[[NSFileManager defaultManager] copyItemAtURL:destinationURL toURL:finalURL error:NULL]; [[NSFileManager defaultManager] removeItemAtURL:destinationURL error:NULL];

// Downloaded file magazine.zip is in finalURL now and in next step I will try to unzip it

[SSZipArchive unzipFileAth:[finalURL path] toDestinan:[[self contentURL]path] overwrite:YES password:nil error:nil];

[self sendEndOfDownloadNotification]; }

And nothing happens. I checked if the file is really located at finalURL path and yes it is. The SSZipArchive has problem to open the magazine.zip file. I tried to find some example how to unzip downloaded Newsstand issue but I didn't find anything.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Luin
  • 1
  • 1

1 Answers1

1

destinationURL is the temporary path of zip file you downloaded. You should directly unzip the file from here to destination

    [SSZipArchive unzipFileAth:[destinationURL path] toDestination:[[self contentURL] URLByAppendingPathComponent:@"magazine.zip"] overwrite:YES password:nil error:nil]; 
//Remove temp file
[[NSFileManager defaultManager] removeItemAtURL:destinationURL error:NULL];
msk
  • 8,885
  • 6
  • 41
  • 72