zip file I/O library for iOS, macOS and tvOS
ZipZap is a zip file I/O library for iOS, macOS and tvOS.
The zip file is an ideal container for compound Objective-C documents. Zip files are widely used and well understood. You can randomly access their parts. The format compresses decently and has extensive operating system and tool support. So we want to make this format an even easier choice for you. Thus, the library features:
As an independent project:
git clone https://github.com/pixelglow/ZipZap.git
.As a project integrated with your own workspace:
cd workspace
then git submodule add https://github.com/pixelglow/ZipZap.git
.Header includes:
#import <ZipZap/ZipZap.h>
Reading an existing zip file:
ZZArchive* oldArchive = [ZZArchive archiveWithURL:[NSURL fileURLWithPath:@"/tmp/old.zip"]
error:nil];
ZZArchiveEntry* firstArchiveEntry = oldArchive.entries[0];
NSLog(@"The first entry's uncompressed size is %lu bytes.", (unsigned long)firstArchiveEntry.uncompressedSize);
NSLog(@"The first entry's data is: %@.", [firstArchiveEntry newDataWithError:nil]);
Writing a new zip file:
ZZArchive* newArchive = [[ZZArchive alloc] initWithURL:[NSURL fileURLWithPath:@"/tmp/new.zip"]
options:@{ZZOpenOptionsCreateIfMissingKey : @YES}
error:nil];
[newArchive updateEntries:
@[
[ZZArchiveEntry archiveEntryWithFileName:@"first.text"
compress:YES
dataBlock:^(NSError** error)
{
return [@"hello, world" dataUsingEncoding:NSUTF8StringEncoding];
}]
]
error:nil];
Updating an existing zip file:
ZZArchive* oldArchive = [ZZArchive archiveWithURL:[NSURL fileURLWithPath:@"/tmp/old.zip"]
error:nil];
[oldArchive updateEntries:
[oldArchive.entries arrayByAddingObject:
[ZZArchiveEntry archiveEntryWithFileName:@"second.text"
compress:YES
dataBlock:^(NSError** error)
{
return [@"bye, world" dataUsingEncoding:NSUTF8StringEncoding];
}]]
error:nil];
Advanced uses: Recipes
API references: References
ZipZap is licensed with the BSD license.