Contents

decompress(using:)

Decompresses the data object’s bytes.

Declaration

func decompress(using algorithm: NSData.CompressionAlgorithm) throws

Parameters

  • algorithm:

    The algorithm to use for decompressing the data. For a list of available algorithms, see Compressionalgorithm.

Discussion

Use this method to inflate in-memory data when you need uncompressed bytes. Specify the same algorithm used to compress the data to successfully decompress it.

The following example shows how to inflate an instance of NSMutableData compressed with the NSData.CompressionAlgorithm.zlib algorithm:

do {
    data.decompress(using: .zlib)
} catch {
    print ("Decompression error: \(error)")
}

See Also

Compressing and Decompressing Data