The usage is as follows:
Create/Add a zip package
ZipArchive * zipFile = [[ZipArchive alloc] init];
// For zipfilename, a complete path is required, for example, ***/Documents/demo.zip.
[ZipFile CreateZipFile2: @ "zipfilename"];
// There are two optional methods to create a compressed package, with or without a password
[[ZipFile CreateZipFile2: @ "zipfilename" Password: @ "your password"];
// Add the file to be compressed to this package
// The complete path is required for the first parameter. For example, ***/Documents/a.txt newname indicates the name of the file in the compressed package.
[ZipFile addFileToZip: @ "fullpath of the file" newname: @ "new name of the file without path"];
// If You Need To Compress multiple files, that is, to compress the folder, repeat the addFileToZip method.
[ZipFile CloseZipFile2];
[ZipFile release];
// Release the memory
Decompress the zip package:
ZipArchive * zipFile = [[ZipArchive alloc] init];
[ZipFile UnzipOpenFile: @ "zip file name"];
// Similarly, there are two methods to open the zip package, with or without a password
[ZipFile UnzipOpenFile: @ "zip file name" Password: @ "password"];
// The location where the compressed package is released. A complete path is required.
[ZipFile UnzipFileTo: @ "output path" overwrite: YES];
[ZipFile UnzipCloseFile];
[ZipFile release];
// Remember to release
From cloud huaikong-abel