Reputation: 1
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.
Upvotes: 0
Views: 924
Reputation: 8905
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];
Upvotes: 1