Execute a terminal command from a Cocoa app

后端 未结 12 2374
既然无缘
既然无缘 2020-11-22 06:34

How can I execute a terminal command (like grep) from my Objective-C Cocoa application?

12条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 07:03

    Custos Mortem said:

    I'm surprised no one really got into blocking/non-blocking call issues

    For blocking/non-blocking call issues regarding NSTask read below:

    asynctask.m -- sample code that shows how to implement asynchronous stdin, stdout & stderr streams for processing data with NSTask

    Source code of asynctask.m is available at GitHub.

提交回复
热议问题