我正在尝试在提交到Mac App Store之前对我的应用进行沙盒处理,我需要打开一个dmg文件。我尝试了以下方法,但是我不知道它是否适用于Apple沙盒。
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/hdiutil"];
[task setArguments:
[NSArray arrayWithObjects: @"attach", [NSString stringWithFormat:@"%@/myfile.dmg", documentsDirectory], nil]];
[task launch];
[task waitUntilExit];
if (0 != [task terminationStatus])
NSLog(@"Mount failed.");
[task release];
如果我将完整路径复制到终端中,它可以工作,但如果从应用程序运行,则会出现以下错误:
diskimages-helper[11437:303] ERROR: couldn't connect to framework.
diskimages-helper[11437:303] DIHelper: setupConnectionToFrameworkWithUUID: failed
hdiutil: attach failed - No child processes
Mount failed.
感谢任何帮助! S.