I want to extend my iPhone app that the app downloads a zip file into a sub directory then extracts it and then load images which were inside the zip.
Any ideas how to unzip in run-time and the access the images? Would be really happy for some idea.
Greetings,
I've used ZipArchive with success in the past.
It's pretty ligthweight and simple to use, supports password protection, multiple files inside a ZIP, as well as compress & decompress.
The basic usage is:
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"ZipFileName" ofType:@"zip"];
ZipArchive *zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:filepath Password:@"xxxxxx"];
[zipArchive UnzipFileTo:{pathToDirectory} overWrite:YES];
[zipArchive UnzipCloseFile];
[zipArchive release];
You cannot extract into your bundle. Use [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
to get the path to a directory you can write to.
You can use the code from http://code.google.com/p/ziparchive/ to extract files from the zip archive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With