终端的以下工作:
open -a cyberduck ftp://anonymous@mirror.switch.ch/mirror
并打开 FTP 站点,表明它正在处理其参数。
但是下面的代码却没有。 Cyberduck 打开正常,但忽略它的参数:
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:
[NSURL fileURLWithPath:@"/Applications/Cyberduck.app"]
options:NSWorkspaceLaunchDefault
configuration:[NSDictionary dictionaryWithObject:
[NSArray arrayWithObject:@"ftp://anonymous@mirror.switch.ch/mirror"]
forKey:NSWorkspaceLaunchConfigurationArguments]
error:&error];
返回时,错误为零。
这是在 Lion 上。我无法使用 openFile:withApplication:,因为参数不是文件名。 (我试过了。)
这确实有效,而且我倾向于使用它:
system("open -a cyberduck ftp://anonymous@mirror.switch.ch/mirror");
有什么想法吗?
最佳答案
关于cocoa - NSWorkspace launchApplicationAtURL 不适用于 NSWorkspaceLaunchConfigurationArguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9420635/