iOS用ZipArchive解压zip包

引入框架 libz.dylib
引入头文件 "ZipArchive.h"

1. 解压:

 1 - (void) extractingArchive {
 2     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
 3    
 4     NSString *filePath = [path stringByAppendingPathComponent:@"luzhan.zip"];
 5     NSString *unZipPath = [path stringByAppendingPathComponent:@"luzhan"];
 6    
 7     ZipArchive *zip = [[ZipArchive alloc] init];
 8    
 9     BOOL result;
10    
11     if ([zip UnzipOpenFile:filePath]) {
12         result = [zip UnzipFileTo:unZipPath overWrite:YES];
13         if (!result) {
14             NSLog(@"解压失败");
15         }
16         else
17         {
18             readBtn.enabled = YES;
19             NSLog(@"解压成功");
20         }
21         [zip UnzipCloseFile];
22     }
23 }

 

posted @ 2013-07-16 10:32  LuZhan  阅读(606)  评论(0编辑  收藏  举报