使用NSTask 挂载dmg 文件

不多说,贴一下代码:1>mount dmg file NSTask * mount = [[NSTask alloc] init]; [mount setLaunchPath: @"/usr/bin/hdiutil"]; [mount setArguments: [NSArray arrayWithObjects: @"unmount", @"-quiet", @"/User/zzc/aa.dmg", nil]]; [mount launch]; [mount waitUntilExit]; [mount release]; } [mount setLaunchPath: @"/usr/bin/hdiutil"]; [mount setArguments: [NSArray arrayWithObjects: @"mount", @"-noidme", @"-quiet", @"-mountroot", @/tmp", @"/User/zzc/aa.dmg", nil]]; [mount launch]; [mount waitUntilExit]; [mount release]; 2->umount dmg file [mount setLaunchPath: @"/usr/bin/hdiutil"]; [mount setArguments: [NSArray arrayWithObjects: @"unmount", @"-quiet", srcPath, nil]]; [mount launch]; [mount waitUntilExit]; [mount release];

 

你可能感兴趣的:(使用NSTask 挂载dmg 文件)