开发者

Can I use NSTask on the iPhone for an app I am not distributing?

开发者 https://www.devze.com 2023-03-19 23:40 出处:网络
I haven\'t been able to find much information about it, but I\'ve seen a few hints that it is possible to use NSTask in an iPhone app. If it is possible, how would I go about doing so?

I haven't been able to find much information about it, but I've seen a few hints that it is possible to use NSTask in an iPhone app. If it is possible, how would I go about doing so?

I don't want to jailbreak my iPhone, but the app I'm developing is for internal use only; it will not be distributed so I don't care if Apple rejects apps that use NSTask.

UPDATE: I went ahead and tried it, and by copying the header file NSTask.h into my project, I was able to successfully compile the code. Good so far. When I ran the code, though, things开发者_开发问答 didn't go as well. I could create a task, and call its setLaunchPath method, but when I tried to launch it, I got a "launch path not accessible" error. The launch path should be fine, though, since the process I'm trying to launch is a program I copied over a socket, and I'm using the same path I used to write the file as I am for the launch path of the task. Does this suggest that the iOS file system is preventing me from accessing the file to launch it, even though I could access that location to open and write a file? Or is it more likely that I'm making another mistake somewhere?


id x = NSClassFromString(@"NSTask");
if (x) {
   NSLog(@"Yes, you can.");
}
else {
   NSLog(@"No, you can not.");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号