Skip to content

Instantly share code, notes, and snippets.

@KatagiriSo
Created December 27, 2011 02:59
Show Gist options
  • Save KatagiriSo/1522593 to your computer and use it in GitHub Desktop.
Save KatagiriSo/1522593 to your computer and use it in GitHub Desktop.
NSTask
NSTask *task = [[NSTask alloc] init];
NSPipe *pipe = [[NSPipe alloc] init];
[task setStandardOutput:pipe];
NSString *launchPath = @"/Applications/Preview.app/Contents/MacOS/Preview";
NSArray *args_ = [NSArray arrayWithObjects:@"/Users/katagiriso/Documents/tmp.pdf",nil];
[task setLaunchPath:launchPath];
[task setArguments:args_];
[task launch];
//[task waitUntilExit];
//NSFileHandle *handle = [pipe fileHandleForReading];
//NSData *data = [handle readDataToEndOfFile];
[task release];
[pipe release];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment