Cocoa/ Objective-C Shell Command Line Execution

后端 未结 3 1295
一向
一向 2020-12-02 21:03

This is probably a stupid question, but how can I execute a shell command from my Cocoa app?

I have the command as a string \"command\", but can easily manipulate da

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 21:45

    If you just want to run something and don't care about the output or return code (for example, you want to touch a file), you can just do

    system("touch myfile.txt");
    

    Easy as that.

提交回复
热议问题