iOS压缩与解压框架SSZipArchive使用详解

来源:互联网 发布:api原油库存数据官网 编辑:程序博客网 时间:2024/05/24 03:00

下载SSZipArchive,点击我。或者自己在这里下载。

SSZipArchive功能:

  1. 解压zip文件
  2. 解压密码保护的zip文件
  3. 创建zip文件
  4. 追加到zip文件
  5. 压缩文件
  6. 使用一个名字来压缩NSData

使用前:

  1. 把SSZipArchive文件添加到项目中
  2. 在target中添加libz.dylib
使用方法:
[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. // 解压  
  2. NSString *zipPath = @"被解压的文件路径";  
  3. NSString *destinationPath = @"解压到的目录";  
  4. [SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath];  
  5.   
  6. // 压缩  
  7. NSString *zippedPath = @"压缩文件路径";  
  8. NSArray *inputPaths = [NSArray arrayWithObjects:  
  9.                        [[NSBundle mainBundle] pathForResource:@"photo1" ofType:@"jpg"],  
  10.                        [[NSBundle mainBundle] pathForResource:@"photo2" ofType:@"jpg"]  
  11.                        nil nil];  
  12. [SSZipArchive createZipFileAtPath:zippedPath withFilesAtPaths:inputPaths];  
0 0
原创粉丝点击