Skip to content

Instantly share code, notes, and snippets.

@rjregenold
Created January 9, 2011 14:27

Revisions

  1. rjregenold revised this gist Jan 9, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions zipkit-example.m
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,10 @@ - (void)inflateArchive {
    [pool drain];
    }

    - (void)inflateComplete {
    // do something after inflate finishes.
    }

    # pragma mark -
    # pragma mark ZKArchive delegate methods

  2. rjregenold revised this gist Jan 9, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions zipkit-example.m
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    - (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]];
  3. rjregenold created this gist Jan 9, 2011.
    30 changes: 30 additions & 0 deletions zipkit-example.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    - (void)inflateArchive {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    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];
    }

    # 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;
    }