Created
January 9, 2011 14:27
-
-
Save rjregenold/771723 to your computer and use it in GitHub Desktop.
A ZipKit example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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