How to zip a directory in iOS with ZipKit?

前端 未结 1 1650
南笙
南笙 2021-01-07 01:18

I need to zip a subdirectory of my Documents folder in an iOS app. After consulting Google and other SO posts, I\'ve found ZipKit and ZipArchive as two open source projects

相关标签:
1条回答
  • 2021-01-07 01:46

    Success. Here's the scoop for anyone else:

    Let's say we want to zip /Documents/myfolder

    NSString *zipFilePath = @"/Documents/zipped.zip";
    ZKFileArchive *archive = [ZKFileArchive archiveWithArchivePath:zipFilePath];
    NSInteger result = [archive deflateDirectory:@"/Documents/myfolder" relativeToPath:@"/Documents" usingResourceFork:NO];
    

    And the zip file is created!

    0 讨论(0)
提交回复
热议问题