Go to file
1024jp 91cb18dd8f Add `isGzipped` proeprty 2016-07-18 00:55:34 +09:00
Documentation Use modulemap instead of bridging header 2015-08-31 18:12:48 +09:00
Project Add `isGzipped` proeprty 2016-07-18 00:55:34 +09:00
Sources Add `isGzipped` proeprty 2016-07-18 00:55:34 +09:00
zlib Use modulemap instead of bridging header 2015-08-31 18:12:48 +09:00
.gitignore Add DS_Store to .gitignore 2015-05-12 00:40:39 +09:00
.travis.yml Update Travis CI image to Xcode8 2016-07-17 18:54:54 +09:00
CHANGELOG.md Add `isGzipped` proeprty 2016-07-18 00:55:34 +09:00
LICENSE Make extension public 2015-05-13 18:49:41 +09:00
README.md Add `isGzipped` proeprty 2016-07-18 00:55:34 +09:00

README.md

NSData+GZIP.swift

Build Status License

NSData+GZIP.swift is an extension of Data written in Swift 3.0. It enables compress/decompress gzip using zlib.

  • Requirements: OS X 10.9 / iOS 7 or later

Usage

// gzip
let compressedData: Data = try! data.gzipped()
let optimizedData: Data = try! data.gzipped(level: .bestCompression)

// gunzip
let decompressedData: Data
if data.isGzipped {
    decompressedData = try! data.gunzipped()
} else {
    decompressedData = data
}

Installation

  1. Add NSData+GZIP.swift file to your project.
  2. Add zlib/ directory to your project.
  3. In Build Phases, add libz.tbd library to your project. screenshot
  4. In Build Settings > Swift Compiler - Search Paths, Add path to zlib/ to Import Paths (SWIFT_INCLUDE_PATHS). screenshot
  5. Invoke from your Swift/ObjC files.

Lisence

© 2014-2016 1024jp

NSData+GZIP.swift is distributed under the terms of the MIT License. See LISENCE for details.