使用命令行启动路径查找器应用程序时,我使用open -a Path Finder.app /Users/
. 基于这个想法,我使用以下代码来启动路径查找器。
我可以在不使用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];