0

My source code is below:

int main(int argc, const char * argv[]) 
{
    char str[80];
    memset(str, 0x00, 80);
    sprintf(str, "%s %s", "open -a","terminal.app");
    NSString *cmdstr = [NSString stringWithUTF8String:str];

    NSTask *task = [NSTask new];
    [task setLaunchPath:@"/bin/sh"];
    [task setArguments:[NSArray arrayWithObjects:@"-c", cmdstr, nil]];

    NSPipe *pipe_out = [NSPipe pipe];
    [task setStandardOutput:pipe_out];

    [task launch];

    NSData *data = [[pipe_out fileHandleForReading] readDataToEndOfFile];

    [task waitUntilExit];

    NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    NSLog(@"%@", string);

}

and here are the questions:

  1. I opened "Terminal Application", my goal is making communication between terminal application and main API through Pipe or somethings. How can I make pipe or something between terminal app and main API?

  2. When the terminal application was opened, I couldn't open new terminal application. How can I open terminal application at new tab or new window?

tshepang
  • 12,111
  • 21
  • 91
  • 136
차지원
  • 1
  • 1

1 Answers1

0

For 2. you'll need to figure out how to use ScriptingBridge

ninjaneer
  • 6,951
  • 8
  • 60
  • 104