With iOS 13 Apple added some convenience methods to NSData to compress and decompress data using a set of compression algorithms. Zlib is recommended as the cross-platform option for interoperating with non-Apple platforms. I recently had need of compressing data while supporting iOS & Android, I did not find much in the way of documented resources to achieve this, so this post is to document what I found.
Compressing Data
The zlib standard supports different levels of compression (an integer between 0 and 9) that tradeoff the speed verses the output size. On iOS the level is fixed to 5 and can not be changed. While with Android the developer can specify any of the levels on the constructor of the Deflater class. Additionally Deflater constructor takes a boolean flag called nowrap, by default Deflater generates a header and ADLER-32 checksum. By setting nowrap to true Deflater will not generate the header or checksum, this make it generate the same bytes as the iOS compressed method.
While the compressed / decompressed methods are available on NSData, unfortunately Apple has not exposed on the swift Data type, so casting to NSData is required.
This article content is really unique and amazing. This article really helpful and explained very well. So I am really thankful to you for sharing keep it up.. Mason Jacob
ReplyDeleteThanks for sharing such a useful blog. Really! This Blog is very informative for us which contains a lot of information about the Writing. I like this post. producthunt
ReplyDeleteblogtalkradio
coub
ali
sketchfab
viki
speakerdeck
magcloud
hearthis
musicbrainz
Service attendants of the lodge speak fluent English, Chinese, Japanese, and different international languages. Those seeking to declare a simple €100 are in luck at Mozzart,BetShah, andFezbetas well as at18Bet,1xBet, andMelbet. You can simply get them atCloudbet, CasinoFair, 1xBit, 카지노사이트 andSpin Sports.888 Sportwill knock you out with their casino bonus packages. Players in South Korea have a host of choices phrases of|in relation to} playing on-line.
ReplyDelete