zipzap version:
ZZArchive* archive = [ZZArchive archiveWithContentsOfURL:[NSURL fileURLWithPath:@"test.zip"]]; NSData* data = [archive.entries[0] newDataWithError:nil];
Or if you are looking for a specific entry:
ZZArchive* archive = [ZZArchive archiveWithContentsOfURL:[NSURL fileURLWithPath:@"test.zip"]]; NSData* data = nil; for (ZZArchiveEntry* entry in archive.entries) if ([entry.fileName isEqualToString:@"test.txt"]) { data = [entry newDataWithError:nil]; break; }
Scanning such files is pretty optimal. The scan uses only the central zip directory and does not actually retrieve data until -[entry newDataWithError:]
.
source share