LoginSignup
2
2

More than 5 years have passed since last update.

NSTaskの使い方

Last updated at Posted at 2012-04-04
  NSTask *task = [[NSTask alloc] init];
  task.launchPath = @"/usr/bin/ruby";

  NSArray *arguments = [NSArray arrayWithObjects:@"arg1", @"arg2", nil];
  task.arguments = arguments;
  NSPipe *pipe = [NSPipe pipe];
  task.standardOutput = pipe;
  NSFileHandle *file = [pipe fileHandleForReading];

  [task launch];
  NSData *data = [file readDataToEndOfFile];
  NSString *retval = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

via http://stackoverflow.com/questions/412562/execute-a-terminal-command-from-a-cocoa-app

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2