首页 > 解决方案 > Objective C launchApplicationAtUrl 参数不起作用

问题描述

我想通过 launchApplicationAtURL 打开带有一些参数的 Photoshop 应用程序。Photoshop 已打开,但我在参数列表中指定的图像未打开。

NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSString *urlString = [NSString stringWithUTF8String:imageEditorPath.GetPlatformString().c_str()];
NSURL *url = [[NSURL alloc] initFileURLWithPath:urlString];
//Handle url==nil
NSError *error = nil;
NSArray *arguments = [NSArray     arrayWithObjects:@"/Users/admin/q/177381.png", nil];
[workspace launchApplicationAtURL:url options:0 configuration: [NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];

标签: objective-cmacosnsworkspace

解决方案


CJK 的回答是正确的:[[NSWorkspace sharedWorkspace] openURLs:fileURLs withApplicationAtURL:appURL options:0 configuration:0 error:&err]; 其中 fileURLs 是要打开的文件数组,appURL 指向应用程序。– 中日韩语

CJK - 请作为答案发送。


推荐阅读