Compression
Leverage compression algorithms for lossless data compression.
Overview
The Compression framework enables your app to provide lossless compression when saving or sharing files and data. Compression is a process in which you compress (encode) and decompress (decode) data. For example, a text editor may save its files in a compressed format, and automatically decompress the saved file when the user opens it.
[Image]
The framework offers two methods of compression:
Buffer compression uses a single-step method for compressing files, making it perfect for use with uncompressed files under 8 MB, or compressed files under 1 MB.
Stream compression uses multiple steps for compressing files, making it ideal for compressing larger files or streamed data, such as an incoming audio signal or downloading files.
To use buffer compression, you compress or decompress the input data with one call to the corresponding function. To learn more about buffer compression, including a walk-through of the code used to encode and decode a string, see Compressing and decompressing data with buffer compression.
To use stream compression, you call the compression or decompression function repeatedly to compress or decompress data from a source buffer to a destination buffer. Between calls, the compressor or decompressor moves processed data out of the source buffer and loads new data into the destination buffer. To learn more about stream compression, see the sample code project Compressing and decompressing files with stream compression.
Topics
Objects that simplify multiple-step compression
Compressing and decompressing data with input and output filtersCompressing and decompressing files with stream compressionInputFilterOutputFilterAlgorithmFilterErrorFilterOperation
Multiple-step compression
compression_streamcompression_stream_init(_:_:_:)compression_stream_process(_:_:)compression_stream_destroy(_:)compression_statuscompression_stream_flagscompression_stream_operationcompression_algorithm