SwiftCompressor

0.1.2

SwiftCompressor lets you use Compression framework easily
DroidsOnRoids/SwiftCompressor

What's New

2016-05-19T09:07:52Z

SwiftCompressor

Version License Platform

Requirements

iOS 9.0+ or OS X 10.11+, Swift 2.x

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

SwiftCompressor is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SwiftCompressor"

Usage

SwiftCompression is a NSData extension. It lets you easily compress/decompress NSData objects this way:

// Create NSData from file
let path = NSBundle.mainBundle().pathForResource("lorem", ofType: "txt")
let loremData = NSData(contentsOfFile: path!)

// Compress and then decompress it!
let compressedData = try? loremData?.compress()
let decompressedData = try? compressedData??.decompress()

// You can also choose one of four algorithms and set a buffer size if you want.
// Available algorithms are LZFSE, LZMA, ZLIB and LZ4.
// Compression without parameters uses LZFSE algorithm. Default buffer size is 4096 bytes.
let compressWithLZ4 = try? loremData?.compress(algorithm: .LZ4)
let compressWithLZMAReallyBigBuffer = try? loremData?.compress(algorithm: .LZMA, bufferSize: 65_536)

Author

Piotr Sochalewski, piotr.sochalewski@droidsonroids.com

License

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

Description

  • Swift Tools
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Jan 31 2023 14:13:33 GMT-0500 (GMT-05:00)