Execute shell script from cocoa (obj.c) with response

前端 未结 4 1172
粉色の甜心
粉色の甜心 2021-01-06 04:57

I have something like:

- (NSString *)unixSinglePathCommandWithReturn:(NSString *)command
{
NSPipe *newPipe = [NSPipe pipe];
NSFileHandle *readHandle = [newPi         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 05:19

    Ah, there's a very important line in the docs you seem to have missed, one of those irritations that NextStep seems to like: "An NSTask object can only be run once. Subsequent attempts to run the task raise an error."

    So, bag the wait, and add [unixTask release] before the return. When you want to run it again, remake the task.

    NSTimer is like this.

提交回复
热议问题