How To Optimize IOS App Performance Using GZIP

How To Optimize IOS App Performance Using GZIP
Social sharing

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 and how to optimize iOS app performance using GZIP.

Contents

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.

Installation

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

- (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.

- (NSData *)gzippedData;

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

- (NSData *)gunzippedData;

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

- (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.

Your recently viewed posts:

Jayadev Das - Post Author

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘About Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

    Contact Us

    We’d love to help & work with you




    When do you want to start ?


    Enter your email address to stay up to date with the latest news.
    Holler Box

    Orange Exit pop up

    Subscribe for the latest
    trends in web and
    mobile app development
    Holler Box

    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