iPhone解压zip文件

 1   // 解压文件
2 NSString *filePath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"sgz.zip"];
3 NSString *unZipedFilePath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"sgz"];
4 NSFileManager *fileManager = [NSFileManager defaultManager];
5 if (![fileManager fileExistsAtPath:filePath]) {
6 return ;
7 }
8 ZipArchive *zipArchive = [[ZipArchive alloc] init];
9 BOOL unZip = [zipArchive UnzipOpenFile:filePath];
10 if ( unZip ) {
11 BOOL unZipOk = [zipArchive UnzipFileTo:unZipedFilePath overWrite:YES];
12 if ( unZipOk ) {
13 }else {
14 printf("解压失败 \n");
15 }
16 }
17 [zipArchive UnzipCloseFile];
18 [zipArchive release];

zipArchive开放源代码地址:http://code.google.com/p/ziparchive/

需要添加的framework: libbz2.1.0dylib

posted on 2011-11-24 21:21  uniy  阅读(2577)  评论(0编辑  收藏  举报

导航