使用开源库ZipArchive
解压:
NSString *zipPath = @"zip压缩包目录";
if ([[NSFileManager defaultManager] fileExistsAtPath:savePath]) {
ZipArchive *zip = [[ZipArchive alloc] init];
if ([zip UnzipOpenFile:savePath]) {
[zip UnzipFileTo:folderPath overWrite:YES];
[zip UnzipCloseFile];
}
}
压缩:
ZipArchive *zip = [[ZipArchive alloc] init];
NSString *zipPath = @"zip包目录";
NSString *resourcePath1 = @"需要压缩的资源1";
NSString *resourcePath2 = @"需要压缩的资源2";
BOOL bRet = [zip CreateZipFile2:sZipPath];
bRet = [zip addFileToZip:img1Path newname:@"resourcePath1"];
bRet = [zip addFileToZip:img2Path newname:@"resourcePath2"];
[zip CloseZipFile2];