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:
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?
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?