升级Catalina之后,我的Mac应用.../file.txt: Operation not permitted
中的一个简单grep提示了此错误。我已经寻找了一段时间,但一直无法使它工作,关于如何解决它的任何想法?
谢谢,这是我正在使用的代码:
- (void)simpleGrep{
NSPipe *pipe = [NSPipe pipe];
NSFileHandle *file = pipe.fileHandleForReading;
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/grep";
task.arguments = @[@"word", @"/Users/xxxxxxx/Documents/SampleFiles/file.txt"];
task.standardOutput = pipe;
[task launch];
NSData *data = [file readDataToEndOfFile];
[file closeFile];
NSString *output = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog (@"Finish with output: %@", output);
}