Teddy13
Teddy13

Reputation: 3854

Add Zip file to project and get location

I have a zipfile called test.zip that I want to add to my xcode project. This zip file will be decompressed the very first time (and only time) the application is launched. Usually when I add files, I just grab them and drag them into my xcode project. I am using the following code from this libary

NSString *zipPath = @"path_to_your_zip_file";
NSString *destinationPath = @"path_to_the_folder_where_you_want_it_unzipped";
[SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath];

Now if I have added the test.zip file by just dragging it into my project, what would my zipPath be? Similar, can anyone also tell me where the proper location to unzip the files would be? I would assume somewhere in the document directory.

Thank you!

Upvotes: 0

Views: 549

Answers (1)

Thilina Chamath Hewagama
Thilina Chamath Hewagama

Reputation: 9040

You can save your file this way, make sure you give correct filename for youzipfilename

NSString *zipPath = [[NSBundle mainBundle] pathForResource:@"youzipfilename" ofType:@"zip"];
NSString *appDirectory = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject];
[SSZipArchive unzipFileAtPath:zipPath toDestination:appDirectory];

Upvotes: 2

Related Questions