我有一个应用程序:TexturePacker。如果我单击应用程序文件夹中的应用程序图标,它将启动 gui。如果我在终端中输入“texturepacker”,它会运行命令行版本。
我想以编程方式启动命令行版本!当我使用下面的代码时,它会启动 GUI。我应该使用什么 shell 命令来启动应用程序(命令行版本),就好像我在终端中输入了“texture packer”一样。
NSTask *theProcess = [[NSTask alloc] init];
[theProcess setLaunchPath:@"/usr/bin/open"];
[theProcess setArguments:[NSArray arrayWithObjects:
@"-a",
@"/Applications/TexturePacker.app",
nil]];
// Arguments to the command: the name of the
// Applications directory
[theProcess launch];
// Run the command
[theProcess release];
如果这是一个菜鸟问题。我道歉。我很笨。:S
编辑:想通了它的一部分。我需要指定应用程序内二进制文件的路径才能启动它。但是我该如何传递参数呢?如果我向数组添加更多参数,shell 会假定它是“open”命令的参数。如果我将它添加到带有纹理打包器路径的字符串中,shell 会说找不到应用程序。:S