Skip to content

Instantly share code, notes, and snippets.

@rjregenold
Created January 9, 2011 14:27
Show Gist options
  • Save rjregenold/771723 to your computer and use it in GitHub Desktop.
Save rjregenold/771723 to your computer and use it in GitHub Desktop.
A ZipKit example.
- (void)inflateArchive {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *archivePath = [self archivePath];
ZKFileArchive *archive = [ZKFileArchive archiveWithArchivePath:archivePath];
[archive setDelegate:self];
[self setArchiveSize:[[[archive centralDirectory] valueForKeyPath:@"@sum.uncompressedSize"] unsignedLongValue]];
[archive inflateToDiskUsingResourceFork:NO];
// do something with inflated archive.
// zipkit puts all inflated files in the same directory as the archive.
[self performSelectorOnMainThread:@selector(inflateComplete) withObject:nil waitUntilDone:NO];
[pool drain];
}
- (void)inflateComplete {
// do something after inflate finishes.
}
# pragma mark -
# pragma mark ZKArchive delegate methods
- (void)onZKArchive:(ZKArchive *) archive didUpdateBytesWritten:(unsigned long long)byteCount {
[self setArchiveProgress:[self archiveProgress] + byteCount];
if ([self archiveSize] <= 0) return;
[[self progressView] setProgress:(float)[self archiveProgress] / (float)[self archiveSize]];
}
- (BOOL)zkDelegateWantsSizes {
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment