Inherits from NSObject
Declared in ZipArchive.h
ZipArchive.mm

Overview

Class for creating and unzipping ZIP files

Usage

  1. Include libz.dylib to your project’s “Link Binaries with Libraries” section of the target settings.

  2. Import ZipArchive.h

    #import "ZipArchive.h"
    
  3. 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

Tasks

Properties

Create zip files

Unzip files

Properties

delegate

Delegate property

@property (nonatomic, weak) id delegate

Declared In

ZipArchive.h

Instance Methods

addFileToZip:newname:

Add file to zip file

- (BOOL)addFileToZip:(NSString *)file newname:(NSString *)newname

Parameters

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.h

closeZipFile

Close the zip file

- (BOOL)closeZipFile

Return Value

Returns YES if successful. NO if failure.

Declared In

ZipArchive.h

createZipFile:

Create zip file

- (BOOL)createZipFile:(NSString *)zipFile

Parameters

zipFile

Path of file to create.

Return Value

Returns YES if successful. NO if failure.

Declared In

ZipArchive.h

createZipFile:password:

Create zip file with password

- (BOOL)createZipFile:(NSString *)zipFile password:(NSString *)password

Parameters

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.h

unzipCloseFile

Close the zip file being unzipped

- (BOOL)unzipCloseFile

Return Value

Returns YES if successful. No if failure.

Declared In

ZipArchive.h

unzipFileTo:overwrite:

Unzip zip file to particular path

- (BOOL)unzipFileTo:(NSString *)path overwrite:(BOOL)overwrite

Parameters

path

Path of directory to where the files will be unzipped.

overwrite

BOOL value 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.h

unzipOpenFile:

Open zip file to unzip

- (BOOL)unzipOpenFile:(NSString *)zipFile

Parameters

zipFile

Path of file to open

Return Value

Returns YES if successful. NO if failure.

Declared In

ZipArchive.h

unzipOpenFile:password:

Open zip file to unzip with password

- (BOOL)unzipOpenFile:(NSString *)zipFile password:(NSString *)password

Parameters

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