How to Optimize iOS App Performance using GZIP

How to Optimize iOS App Performance using GZIP

iOS App Performance
< 1 Minute Read

Gzip is a popular method of compressing files for faster network transfers. But not many are aware that it can be implemented on iOS apps too. Here’s how it works:

Supported OS & SDK Versions

●     Supported build target – iOS 8.4/MacOS 10.10 (Xcode 6.4, Apple LLVM compiler 6.1)

●     Earliest supported deployment target – iOS 7.0/MacOS 10.9

●     Earliest compatible deployment target – iOS 4.3/MacOS 10.6

ARC Compatibility

The GZIP category will work correctly in either ARC or non-ARC projects without modification.

Thread Safety

All the GZIP methods are thread safe. Hence, it’s easy to say that these methods can be called from multiple threads concurrently.


It’s pretty easy. Just drag the category files (test files & assets not needed) into your project & import the header file into any class where you wish to use the GZIP functionality. No need to include the libz.dylib, as GZIP locates it automatically at runtime.

NSData Extensions

[code language=”html”]
– (NSData *)gzippedDataWithCompressionLevel:(float)level;

In this method, the compression level is a floating point value between 0.0 & 1.0. In case a negative value is supplied, the default compression level is around 0.7.

[code language=”html”]
– (NSData *)gzippedData;

This is equivalent to calling gzippedDataWithCompressionLevel, with the default compression level.

[code language=”html”]
– (NSData *)gunzippedData;

It unzips the compressed data using deflate algorithm & returns the output.

[code language=”html”]
– (BOOL)isGzippedData;

This method returns ‘Yes’ if the data is gzip-encoded.

Biggest Advantage:
Quick upload/download of data from server to client & vice versa.

Have you used GZIP Compression before? Did I leave anything out? Share your experiences/feedback/suggestions below.

No Comments

Post A Comment

Exit pop up

Sad to see you leaving early...

From "Aha" to "Oh shit" we are sharing everything on our journey.
Enter your email address to stay up to date with the latest news.
Holler Box