2012-02-13 81 views
0

我正在开发典型的报摊应用程序,并且解压缩下载的文件时遇到问题。xcode解压缩下载问题

-(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]; }

没有任何反应。我检查了该文件是否确实位于finalURL路径中,是的。 SSZipArchive有问题打开magazine.zip文件。我试图找到一些例子,如何解压下载的Newsstand问题,但我没有找到任何东西。

回答

1

destinationURL是您下载的zip文件的临时路径。你应该直接将文件解压缩从这里到目的地

[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];