我正在尝试在提交到 Mac App Store 之前对我的应用程序进行沙箱处理,并且我需要打开一个 dmg 文件。我尝试了以下方法,但我不知道它是否应该与 Apple Sandbox 一起使用。
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。