知道为什么要这么叫吗,
NSTask *buildMTask = [[NSTask alloc] init];
[buildMTask setLaunchPath:@"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\\ Simulator.app/Contents/MacOS/iPhone\\ Simulator"];
[buildMTask launch];结果:
“发射路径无法访问”?
谢谢!
发布于 2012-10-17 17:26:20
NSString *appname = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator";
NSTask *aTask = [[NSTask alloc] init];
[aTask setLaunchPath:appname];
BOOL exists = [[NSFileManager defaultManager] isExecutableFileAtPath:[aTask launchPath]];
NSLog(@"%@ '%@'\n", exists ? @"Exists" : @"Does Not Exist", [aTask launchPath]);
[aTask launch];工作正常,甚至记录可执行文件的存在。删除可执行名称中的\\ -所有这些。
在尝试运行应用程序之前,我建议使用可执行的存在性检查。
https://stackoverflow.com/questions/12938772
复制相似问题