Latest 2.1.1
Homepage https://github.com/mattt/Godzippa
License MIT
Platforms ios 6.0, osx 10.8, watchos 2.0, tvos 9.0, requires ARC
Authors

Godzippa!

Build Status
License
Swift Version
Cocoapods platforms
Cocoapods compatible
Carthage compatible

gzip Compression / Decompression Category for NSData & NSFileManager

CocoaPods

You can install Godzippa via CocoaPods,
by adding the following line to your Podfile:

pod 'Godzippa', '~> 2.1.1'

Run the pod install command to download the library
and integrate it into your Xcode project.

Carthage

To use Godzippa in your Xcode project using Carthage,
specify it in Cartfile:

github "mattt/Godzippa" ~> 2.1.1

Then run the carthage update command to build the framework,
and drag the built Godzippa.framework into your Xcode project.

Manual Installation

Copy the .h and .m files in the Sources directory to your project.
In the "Link Binary With Libraries" Build Phase of your Target,
add libz.dylib.

Usage

Objective-C

NSData

NSData *originalData = [@"Look out! It's..." dataUsingEncoding:NSUTF8StringEncoding];
NSData *compressedData = [originalData dataByGZipCompressingWithError:nil];
NSData *decompressedData = [compressedData dataByGZipDecompressingDataWithError:nil];
NSLog(@"%@ %@", [NSString stringWithUTF8String:[decompressedData bytes]], @"Godzippa!");

NSFileManager

NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *file = [NSURL fileURLWithPath:@"/path/to/file.txt"];
NSError *error = nil;

[fileManager GZipCompressFile:file
        writingContentsToFile:[file URLByAppendingPathExtension:@"gz"]
                        error:&error];

Swift

NSData

let originalString = "Look out! It's Godzippa!"
let originalData = originalString.data(using: .utf8)! as NSData
let compressedData = try! originalData.gzipCompressed() as NSData
let decompressedData = try! compressedData.gzipDecompressed()
let decompressedString = String(data: decompressedData, encoding: .utf8)

FileManager

let fileManager = FileManager.default
let textFile = URL(fileURLWithPath: "/path/to/file.txt")
let gzipFile = textFile.appendingPathExtension("gz")
try fileManager.gzipCompressFile(at: textFile, to: gzipFile)

Contact

Mattt (@mattt)

License

Godzippa! is available under the MIT license.
See the LICENSE file for more info.

Latest podspec

{
    "name": "Godzippa",
    "version": "2.1.1",
    "license": "MIT",
    "summary": "GZip Compression / Decompression Category for NSData and NSFileManager.",
    "homepage": "https://github.com/mattt/Godzippa",
    "social_media_url": "https://twitter.com/mattt",
    "authors": {
        "Mattt": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mattt/Godzippa.git",
        "tag": "2.1.1"
    },
    "source_files": "Sources/*.{h,m}",
    "requires_arc": true,
    "platforms": {
        "ios": "6.0",
        "osx": "10.8",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "libraries": "z"
}

Pin It on Pinterest

Share This