Name: SwiftCompressor
Owner: Droids On Roids
Description: SwiftCompressor lets you use Compression framework easily
Created: 2016-02-24 12:01:05.0
Updated: 2018-04-12 05:20:41.0
Pushed: 2016-09-26 08:48:15.0
Homepage: http://www.thedroidsonroids.com/
Size: 64
Language: Shell
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
iOS 9.0+, macOS 10.11+, watchOS 2.0+, tvOS 9.0+
Swift 3
To run the example project, clone the repo, and run pod install
from the Example directory first.
SwiftCompressor is available through CocoaPods. To install it, simply add the following line to your Podfile:
"SwiftCompressor"
SwiftCompression is a Data
extension. It lets you easily compress/decompress Data
objects this way:
reate NSData from file
path = URL(fileURLWithPath: Bundle.main.path(forResource: "lorem", ofType: "txt")!)
loremData = try? Data(contentsOf: path)
ompress and then decompress it!
compressedData = try? loremData?.compress()
decompressedData = try? compressedData??.decompress()
ou can also choose one of four algorithms and set a buffer size if you want.
vailable algorithms are LZFSE, LZMA, ZLIB and LZ4.
ompression without parameters uses LZFSE algorithm. Default buffer size is 4096 bytes.
compressWithLZ4 = try? loremData?.compress(algorithm: .lz4)
compressWithLZMAReallyBigBuffer = try? loremData?.compress(algorithm: .lzma, bufferSize: 65_536)
Piotr Sochalewski, piotr.sochalewski@droidsonroids.com
SwiftCompressor is available under the MIT license. See the LICENSE file for more info.