本文转载至 http://www.apkbus.com/forum.php?mod=viewthread&tid=131390&extra=page%3D1
|
1、在Frameworks中加入libz.dylib库
2、在项目中加入ZipArchive的相关文件
3、简单示例
- NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
- //设置ZIP文件路径
- NSString *filePath = [path stringByAppendingPathComponent:@"book.zip"];
- //设置解压文件夹的路径
- NSString *unZipPath = [path stringByAppendingPathComponent:@"books"];
- //初始化ZipArchive
- ZipArchive *zip = [[ZipArchive alloc] init];
- BOOL result;
- if ([zip UnzipOpenFile:filePath]) {
- //解压文件
- result = [zip UnzipFileTo:unZipPath overWrite:YES];
- if (!result) {
- //解压失败
- NSLog(@"unzip fail");
- }else {
- //解压成功
- NSLog(@"unzip success");
- }
- [zip UnzipCloseFile];//关闭
- }
- [zip release];
复制代码
<ignore_js_op> ZipArchive.zip (72.93 KB, 下载次数: 14) |
|