1024jp / GzipSwift

Swift package that enables gzip/gunzip Data using zlib
MIT License
533 stars 132 forks source link

cannot use in OC project #26

Closed chunxige closed 6 years ago

1024jp commented 6 years ago

What's the OC project? Objective-C?

chunxige commented 6 years ago

yes , I import the framework in Objective-C project, it cannot use

1024jp commented 6 years ago

As the name represents, GzipSwift is for Swift. Therefore, I don't recommend to use GzipSwift in ObjC project.

However, if you yet want to use GzipSwift in Objective-C for some reason, You need to add a bridge code to use Swift.Data methods in NSData, something like this:

import Gzip

public extension NSData {

    @objc func gunzippedData() -> NSData? {

        return (try? (self as Data).gunzipped()) as NSData?
    }

    @objc func gzippedData() -> NSData? {

        return (try? (self as Data).gzipped()) as NSData?
    }
}