ZipArchive Class Reference
| Inherits from | NSObject |
| Declared in | ZipArchive.h ZipArchive.mm |
Overview
Class for creating and unzipping ZIP files
Usage
Include
libz.dylibto your project’s “Link Binaries with Libraries” section of the target settings.Import
ZipArchive.h#import "ZipArchive.h"If unzipping file, the code might look like:
NSString *subdirectory = @"archive"; // the folder name to which you will unzip the files NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSString *archivePath = [documentsPath stringByAppendingPathComponent:subdirectory]; ZipArchive *za = [[ZipArchive alloc] init]; if ([za unzipOpenFile:path]) { BOOL ret = [za unzipFileTo:archivePath overwrite:YES]; NSAssert(ret, @"Unzip failed"); }
See also
- This is based upon aish’s original ZipArchive class
- This includes version 1.01h of Minizip
Tasks
Properties
-
delegateDelegate property
property
Create zip files
-
– createZipFile:Create zip file
-
– createZipFile:password:Create zip file with password
-
– addFileToZip:newname:Add file to zip file
-
– closeZipFileClose the zip file
Unzip files
-
– unzipOpenFile:Open zip file to unzip
-
– unzipOpenFile:password:Open zip file to unzip with password
-
– unzipFileTo:overwrite:Unzip zip file to particular path
-
– unzipCloseFileClose the zip file being unzipped
Instance Methods
addFileToZip:newname:
Add file to zip file
- (BOOL)addFileToZip:(NSString *)file newname:(NSString *)newnameParameters
- file
Path of file to create
- newname
The new name of the file
Return Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.hcloseZipFile
Close the zip file
- (BOOL)closeZipFileReturn Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.hcreateZipFile:
Create zip file
- (BOOL)createZipFile:(NSString *)zipFileParameters
- zipFile
Path of file to create.
Return Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.hcreateZipFile:password:
Create zip file with password
- (BOOL)createZipFile:(NSString *)zipFile password:(NSString *)passwordParameters
- zipFile
Path of file to create
- password
The password to use when creating the zip file.
Return Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.hunzipCloseFile
Close the zip file being unzipped
- (BOOL)unzipCloseFileReturn Value
Returns YES if successful. No if failure.
Declared In
ZipArchive.hunzipFileTo:overwrite:
Unzip zip file to particular path
- (BOOL)unzipFileTo:(NSString *)path overwrite:(BOOL)overwriteParameters
- path
Path of directory to where the files will be unzipped.
- overwrite
BOOLvalue indicating whether the files at the path should be overwritten if already found.
Return Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.hunzipOpenFile:
Open zip file to unzip
- (BOOL)unzipOpenFile:(NSString *)zipFileParameters
- zipFile
Path of file to open
Return Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.hunzipOpenFile:password:
Open zip file to unzip with password
- (BOOL)unzipOpenFile:(NSString *)zipFile password:(NSString *)passwordParameters
- zipFile
Path of file to open
- password
The password to use when opening the zip file.
Return Value
Returns YES if successful. NO if failure.
Declared In
ZipArchive.h