Home / Programming / mac / osx / cocoa / swift edit

 
swift  
Nibless cocoa:
code signing and notorization
autolayout
wkwebview
cocoa articles
cocoa libraries
cocoa apps and libraries
cocoa search kit
quick look plugins
unzip in cocoa
// http://stackoverflow.com/questions/2296667/unzipping-a-file-in-cocoa
- (void) unzip {
    NSFileManager* fm = [NSFileManager defaultManager];
    NSString* zipPath = @"myFile.zip";

    NSString* targetFolder = @"/tmp/unzipped"; //this it the parent folder
                                               //where your zip's content 
                                               //goes to (must exist)

    //create a new empty folder (unzipping will fail if any
    //of the payload files already exist at the target location)
    [fm createDirectoryAtPath:targetFolder withIntermediateDirectories:NO 
                                           attributes:nil error:NULL];


    //now create a unzip-task
    NSArray *arguments = [NSArray arrayWithObject:zipPath];
    NSTask *unzipTask = [[NSTask alloc] init];
    [unzipTask setLaunchPath:@"/usr/bin/unzip"];
    [unzipTask setCurrentDirectoryPath:targetFolder];
    [unzipTask setArguments:arguments];
    [unzipTask launch];
    [unzipTask waitUntilExit]; //remove this to start the task concurrently

}
NSButton
blogs and websites
NSTextView
Links
JavaScriptCore
 
Go to index of articles.

Share on