【发布时间】:2011-02-19 03:35:38
【问题描述】:
使用命令行启动路径查找器应用程序时,我使用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];
【问题讨论】:
标签: objective-c cocoa launching-application