Sample code for 30+ languages & platforms
Objective-C

Ungzip Base64 String

See more Gzip Examples

Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.

Chilkat Objective-C Downloads

Objective-C
#import <CkoGzip.h>
#import <NSString.h>
#import <CkoBinData.h>

BOOL success = NO;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoGzip *gzip = [[CkoGzip alloc] init];

NSString *gzipBase64 = @"H4sIAAAAAAAE ... X6aZjXO3EwAA";

CkoBinData *bd = [[CkoBinData alloc] init];
success = [bd AppendEncoded: gzipBase64 encoding: @"base64"];

success = [gzip UncompressBd: bd];
if (success != YES) {
    NSLog(@"%@",gzip.LastErrorText);
    return;
}

NSString *strXml = [bd GetString: @"utf-8"];
NSLog(@"%@",@"XML:");
NSLog(@"%@",strXml);