NSPipe and System() - iPhone SDK Cocoa
I need to add this section into my application where the user would enter in a terminal command for example "killall SpringBoard" and when the user presses the button it would run the command. I know that if you use the System("") function you can run the te开发者_运维百科rminal command. But how about from a textbox?
My next question is if it is possible to retrieve the result of the terminal command using NSPipe? If so how? Note I am using the phrase 'terminal command' since i'm not really sure what its called (If someone knows please tell me...). Basically the same thing as the commands in MobileTerminal...
Thanks,
Kevin
If you plan on submitting your app to the AppStore, it will never get approved with a feature set like that.
… how about from a textbox?
Rhetorical question: What do your views have to do with the system
function?
My next question is if it is possible to retrieve the result of the terminal command using NSPipe?
Yes.
If so how?
Abandon the system
function, and use fork
and one of the exec
functions directly. (There's no NSTask on the iPhone—not in the iPhone API documentation, anyway.)
Considering your plan is to kill the SpringBoard, I hope that you're targeting the jailbreak platform, not the App Store. Like greg, I would expect Apple to reject your app if you try any such thing. I can't even imagine why you want to do that.
精彩评论