2014-12-08 05:09:33 +08:00
|
|
|
|
2016-07-28 23:37:32 +08:00
|
|
|
GzipSwift
|
2014-12-08 05:09:33 +08:00
|
|
|
========================
|
|
|
|
|
2016-07-28 23:41:01 +08:00
|
|
|
[![macOS](https://img.shields.io/badge/macOS-10.9%2B-blue.svg)]()
|
|
|
|
[![iOS](https://img.shields.io/badge/iOS-8.0%2B-blue.svg)]()
|
2016-07-29 00:06:56 +08:00
|
|
|
[![watchOS](https://img.shields.io/badge/watchOS-2.0%2B-blue.svg)]()
|
|
|
|
[![tvOS](https://img.shields.io/badge/tvOS-9.0%2B-blue.svg)]()
|
2016-07-28 23:41:01 +08:00
|
|
|
[![Swift](https://img.shields.io/badge/Swift-3.0-blue.svg)]()
|
|
|
|
[![Carthage compatible](https://img.shields.io/badge/Carthage-✓-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
|
2016-07-29 00:24:00 +08:00
|
|
|
[![Build Status](https://img.shields.io/travis/1024jp/GzipSwift/master.svg?style=flat)](https://travis-ci.org/1024jp/GzipSwift)
|
|
|
|
[![License](https://img.shields.io/github/license/1024jp/GzipSwift.svg)](https://github.com/1024jp/GzipSwift/blob/develop/LICENSE)
|
2015-05-12 11:13:49 +08:00
|
|
|
|
2016-08-13 13:28:55 +08:00
|
|
|
__GzipSwift__ is a framework with an extension of Data written in Swift. It enables compress/decompress gzip using zlib.
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2016-07-29 00:06:56 +08:00
|
|
|
- __Requirements__: OS X 10.9 / iOS 8 / watchOS 2 / tvOS 9 or later
|
2016-08-16 16:59:49 +08:00
|
|
|
- __Swift version__: 3.0 (beta 6)
|
2014-12-08 05:09:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```swift
|
2016-07-28 20:26:03 +08:00
|
|
|
import Gzip
|
|
|
|
|
2014-12-08 05:09:33 +08:00
|
|
|
// gzip
|
2016-07-17 23:55:34 +08:00
|
|
|
let compressedData: Data = try! data.gzipped()
|
|
|
|
let optimizedData: Data = try! data.gzipped(level: .bestCompression)
|
2014-12-08 05:09:33 +08:00
|
|
|
|
|
|
|
// gunzip
|
2016-07-17 23:55:34 +08:00
|
|
|
let decompressedData: Data
|
|
|
|
if data.isGzipped {
|
|
|
|
decompressedData = try! data.gunzipped()
|
|
|
|
} else {
|
|
|
|
decompressedData = data
|
|
|
|
}
|
|
|
|
|
2016-07-28 20:26:03 +08:00
|
|
|
// check data is gzipped
|
2016-07-29 06:05:23 +08:00
|
|
|
print(compressedData.isGzipped)
|
2014-12-08 05:09:33 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2016-07-28 23:37:32 +08:00
|
|
|
1. Build Gzip framework.
|
|
|
|
3. In *Build Phases*, add `Gzip.framework` library to your project.
|
2016-07-29 00:24:00 +08:00
|
|
|
<br /><img src="Documentation/binary_link@2x.png" height="150"/>
|
2016-07-28 20:26:03 +08:00
|
|
|
5. `import Gzip` in your Swift file.
|
|
|
|
6. Use in your code.
|
2014-12-08 05:09:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
## Lisence
|
|
|
|
|
2016-07-17 17:07:26 +08:00
|
|
|
© 2014-2016 1024jp
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2016-07-28 23:37:32 +08:00
|
|
|
GzipSwift is distributed under the terms of the __MIT License__. See [LISENCE](LISENCE) for details.
|