首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSTask发射路径误差

NSTask发射路径误差
EN

Stack Overflow用户
提问于 2012-10-17 16:19:01
回答 1查看 860关注 0票数 0

可能重复: NSTask launch path not accessible

知道为什么要这么叫吗,

代码语言:javascript
复制
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];

结果:

“发射路径无法访问”?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2012-10-17 17:26:20

代码语言:javascript
复制
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];

工作正常,甚至记录可执行文件的存在。删除可执行名称中的\\ -所有这些。

在尝试运行应用程序之前,我建议使用可执行的存在性检查。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12938772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档