Latest 1.0.1
Homepage https://github.com/chris-huxtable/CBHCompressKit
License ISC
Platforms osx 10.11
Authors

release
pod
licence
coverage

CBHCompressKit provides CBHCompressor and CBHDecompressor which provide an easy-to-use means of compressing NSData. They support one-call and stream compression. Additionally CBHCompressKit provides a NSData category to make one-call compression even easier.

Supported Algorithms:

  • LZ4: A high-speed compression algorithm.
  • LZMA: A high compression ratio algorithm.
  • ZLib: A balanced, cross platform compression algorithm/format.
  • LZFSE: A balanced, Apple only compression algorithm.

Use

Most use cases will only need to use the NSData categories.

Examples:

Compress NSData with LZ4:

NSData *data = /* some data */
NSData *compressed = [data compressUsingLZ4];

Decompress NSData with LZ4:

NSData *compressed = /* some compressed data */
NSData *data = [compressed decompressUsingLZ4];

Compress NSData with LZMA:

NSData *data = /* some data */
NSData *compressed = [data compressUsingLZMA];

Decompress NSData with LZMA:

NSData *compressed = /* some compressed data */
NSData *data = [compressed decompressUsingLZMA];

Compress NSData with ZLib:

NSData *data = /* some data */
NSData *compressed = [data compressUsingZLib];

Decompress NSData with ZLib:

NSData *compressed = /* some compressed data */
NSData *data = [compressed decompressUsingZLib];

Compress NSData with LZFSE:

NSData *data = /* some data */
NSData *compressed = [data compressUsingLZFSE];

Decompress NSData with LZFSE:

NSData *compressed = /* some compressed data */
NSData *data = [compressed decompressUsingLZFSE];

More complicated examples such as with a stream.

Examples:

Compress a stream:

id io = /* an object that returns data in chunks */

CBHCompressAlgorithm algorithm = CBHCompressAlgorithm_LZMA;
NSData *compressed = [CBHCompressor compressUsingAlgorithm:algorithm inBlock:^(CBHCompressor *compressor) {
    while ( [io hasMoreData] )
    {
        [compressor appendData:[io data]];
    }
}];

Decompress a stream:

id io = /* an object that returns data in chunks */

CBHCompressAlgorithm algorithm = CBHCompressAlgorithm_LZMA;
NSData *decompressed = [CBHDecompressor decompressUsingAlgorithm:algorithm inBlock:^(CBHDecompressor *decompressor) {
    while ( [io hasMoreData] )
    {
        [decompressor appendData:[io data]];
    }
}];

Licence

CBHCompressKit is available under the ISC license.

Latest podspec

{
    "name": "CBHCompressKit",
    "version": "1.0.1",
    "module_name": "CBHCompressKit",
    "summary": "CBHCompressKit provides `CBHCompressor` and `CBHDecompressor` which provide an easy-to-use means of compressing `NSData`.",
    "homepage": "https://github.com/chris-huxtable/CBHCompressKit",
    "license": {
        "type": "ISC",
        "file": "LICENSE"
    },
    "authors": {
        "Chris Huxtable": "[email protected]"
    },
    "social_media_url": "https://twitter.com/@Chris_Huxtable",
    "platforms": {
        "osx": "10.11"
    },
    "source": {
        "git": "https://github.com/chris-huxtable/CBHCompressKit.git",
        "tag": "v1.0.1"
    },
    "requires_arc": false,
    "public_header_files": "CBHCompressKit/*.h",
    "source_files": "CBHCompressKit/*.{h,m}"
}

Pin It on Pinterest

Share This