简单使用:
NSString *namePath = [[NSBundle mainBundle] pathForResource:@"name" ofType:@"txt"];
NSString *agePath = [[NSBundle mainBundle] pathForResource:@"age" ofType:@"txt"];
//压缩 可以不设置密码
NSString *zipPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"Test.zip"];
ZipArchive *zip = [[ZipArchive alloc] init];
[zip CreateZipFile2:zipPath Password:@"123"];
BOOL result =[zip addFileToZip:namePath newname:@"name.txt"];
result = [zip addFileToZip:agePath newname:@"age.txt"];
result = [zip CloseZipFile2];
[zip release];
//解压
NSString *unzipPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"Test"];
ZipArchive *unzip = [[ZipArchive alloc] init];
BOOL ret = [unzip UnzipOpenFile:zipPath Password:@"123"];
ret = [unzip UnzipFileTo:unzipPath overWrite:NO];
[unzip UnzipCloseFile];
[unzip release];