当通过命令行启动Path Finder应用程序时,我使用open -a Path Finder.app /Users/
命令。
基于这个想法,我使用下面的代码来启动Path Finder。
我能否在不使用open
命令行的情况下启动应用程序?
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/open"];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-a", @"Path Finder.app", @"/Users/", nil];
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
argc
和argv
。 - ughoavgfhw