I am new in iOS and want to Know that Is there any way to store file in app like a .rar or zip file and extract files when required.
Asked
Active
Viewed 225 times
0
-
1You have 2 questions here: Storing files and extract files. Yes, you can store files in iOS App. See [this](http://stackoverflow.com/questions/6029916/how-to-enable-file-sharing-for-my-app). For extracting files, there are tons of tutorials online – Raptor May 07 '14 at 10:43
2 Answers
2
You can use ZipArchive, a private third party class to archive and extract the file.
And, the usage of ZipArchive can be found here.

Community
- 1
- 1

Shiva Kumar Ganthi
- 426
- 4
- 18
-
Thanks But Also tell me that Is this a good way to store file in app in this way like Videos or images etc. – Syed Sharjeel Ali May 07 '14 at 11:34
-
Ofcourse, you could archive the file(an image or a video) and store that in documents folder of your app. But, your app may have the possibility to consume more memory in future times as usage of the app goes on. – Shiva Kumar Ganthi May 07 '14 at 11:44
2
You can do this by using ZipArchive
Here is the complete tutorial for zip and unzip file.
http://transoceanic.blogspot.in/2011/07/compressuncompress-files-on.html
Uncompress zip file example:
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *zipFilePath = [documentsDirectory stringByAppendingPathComponent:@"myZipFileName.zip"];
NSString *output = [documentsDirectory stringByAppendingPathComponent:@"unZipDirName"];
ZipArchive* za = [[ZipArchive alloc] init];
if( [za UnzipOpenFile:zipFilePath] ) {
if( [za UnzipFileTo:output overWrite:YES] != NO ) {
//unzip data success
//do something
}
[za UnzipCloseFile];
}
[za release];

Divya Bhaloidiya
- 5,018
- 2
- 25
- 45