使用命令行启动Path Finder应用程序时,我使用open -a Path Finder.app /Users/
。 基于这个想法,我使用下面的代码来启动Path Finder。使用Objective-C/Cocoa启动Mac应用程序
我可以使用启动应用程序而不使用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];
如何给参数? – prosseek 2011-02-19 05:07:13