Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSTask *task = [[NSTask alloc] init];
- [task setLaunchPath: @"/usr/bin/grep"];
- [task setArguments: @[ @"foo", @"bar.txt"]];
- NSPipe *pipe = [NSPipe pipe];
- [task setStandardOutput: pipe];
- [task launch];
- NSFileHandle *file = [pipe fileHandleForReading];
- NSString *string = [[NSString alloc] initWithData: [file readDataToEndOfFile]
- encoding: NSUTF8StringEncoding];
- NSLog (@"grep returned:\n%@", string);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement