Here's a more concise version based on the codingFriend1 approach
+ (void)unzip { NSString *targetFolder = @"/tmp/unzipped"; NSString* zipPath = @"/path/to/my.zip"; NSTask *task = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/unzip" arguments:@[@"-o", zipPath, @"-d", targetFolder]]; [task waitUntilExit]; }
-d specifies the destination directory to be created by unpacking if it does not exist
-o says unzip to overwrite existing files (but not to delete obsolete files, so keep in mind)
There are no validation errors and more, but it is a simple and quick solution.
source share