使用第三方框架-第三方解压缩框架——ZipArchive
下载地址:https://github.com/ZipArchive/ZipArchive
需要引入libz.dylib框架
导入头文件Main.h
- 创建压缩文件
+ (BOOL)createZipFileAtPath:(NSString *)path
withFilesAtPaths:(NSArray *)paths;
-(void)zip { NSArray *arrayM =@[ @"/Users/xiaomage/Desktop/Snip20151009_358.png", @"/Users/xiaomage/Desktop/Snip20151009_359.png", @"/Users/xiaomage/Desktop/Snip20151009_357.png" ]; /* 第一个参数:创建的zip放在哪里 第二个参数:要压缩哪些文件 */ [Main createZipFileAtPath:@"/Users/xiaomage/Desktop/demo.zip" withFilesAtPaths:arrayM]; }
+ (BOOL)createZipFileAtPath:(NSString *)path
withContentsOfDirectory:(NSString *)directoryPath;
-(void)zip2 { /* 第一个参数:创建的zip放在哪里 第二个参数:要压缩的文件路径 */ [Main createZipFileAtPath:@"/Users/xiaomage/Desktop/vvv.zip" withContentsOfDirectory:@"/Users/xiaomage/Desktop/demo"]; }
- 解压
+ (BOOL)unzipFileAtPath:(NSString *)path
toDestination:(NSString *)destination
-(void)unZip { /* 第一个参数:要解压的文件在哪里 第二个参数:文件要放到什么地方 */ [Main unzipFileAtPath:@"/Users/xiaomage/Desktop/vvv.zip" toDestination:@"/Users/xiaomage/Desktop/yy"]; }
浙公网安备 33010602011771号