Compression and decompression in iOS development

Source: Internet
Author: User

In fact, in iOS development, compression and decompression, I was implemented using a third-party framework Ssziparchive

GitHub Address: Https://github.com/ZipArchive/ZipArchive

There are detailed methods of use

Because Ziparchive does not support arc, if your project opens arc, then you need to set the Ziparchive . In the Ziparchive. MM compilation option, add-fno-objc-arc.

Finally, the Libz.dylib dynamic link library needs to be linked to the project .

Use demonstration (compression):

Get the picture path of all png in Mainbundle    nsarray *pngs = [[NSBundle mainbundle] pathsforresourcesoftype:@ "PNG" Indirectory:nil ];        Zip file path    nsstring *caches = [Nssearchpathfordirectoriesindomains (nscachesdirectory, Nsuserdomainmask, YES) Lastobject];    NSString *zipfilepath = [Caches stringbyappendingpathcomponent:@ "Pngs.zip"];        Create a ZIP file    

Extract:

  NSString *caches = [Nssearchpathfordirectoriesindomains (nscachesdirectory, Nsuserdomainmask, YES) lastObject];  NSString *filepath = [caches stringbyappendingpathcomponent:@ "file name. zip"];  Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{           //decompression (file size, it will be more time-consuming, so put in the sub-thread decompression)          [ssziparchive Unzipfileatpath:filepath todestination:caches];       });

Compression and decompression in iOS development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.