Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 目标C启动应用程序URL参数不工作_Objective C_Macos_Nsworkspace - Fatal编程技术网

Objective c 目标C启动应用程序URL参数不工作

Objective c 目标C启动应用程序URL参数不工作,objective-c,macos,nsworkspace,Objective C,Macos,Nsworkspace,我想通过LaunchApplicationaURL打开带有一些参数的Photoshop应用程序。Photoshop已打开,但我在参数列表中指定的图像未打开 NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; NSString *urlString = [NSString stringWithUTF8String:imageEditorPath.GetPlatformString().c_str()]; NSURL *url = [[NS

我想通过LaunchApplicationaURL打开带有一些参数的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];
CJKs的答案是正确的: [[NSWorkspace sharedWorkspace]OpenURL:FileURL和ApplicationURL:appURL选项:0配置:0错误:&err];其中FileURL是要打开的文件数组,appURL指向应用程序CJK

CJK-请将其作为答案发送。

CJK的答案正确: [[NSWorkspace sharedWorkspace]OpenURL:FileURL和ApplicationURL:appURL选项:0配置:0错误:&err];其中FileURL是要打开的文件数组,appURL指向应用程序CJK


CJK-请将其作为答案发送。

参考我的上述评论,可以使用
NSWorkspace
方法在应用程序中打开多个文件。如果您不需要向应用程序发送任何参数,或为应用程序设置环境变量,则只需将
NULL
传递给
配置:
参数即可。同样,也有,但如果这些都不需要,可以将
0
传递给
选项:
参数:

NSURL *appURL = [NSURL fileURLWithPath:@"file:///path/to/application.app"];
NSArray *fileURLs = [NSArray arrayWithObjects:[NSURL fileURLWithPath:@"file:///path/to/file1"],
                                              [NSURL fileURLWithPath:@"file:///path/to/file2"],
                                              nil];
NSError *err = nil;
BOOL success = [[NSWorkspace sharedWorkspace] openURLs:fileURLs withApplicationAtURL:appURL 
                                              options:0 configuration:NULL error:&err];

参考我上面的评论,可以使用
NSWorkspace
方法在应用程序中打开多个文件。如果您不需要向应用程序发送任何参数,或为应用程序设置环境变量,则只需将
NULL
传递给
配置:
参数即可。同样,也有,但如果这些都不需要,可以将
0
传递给
选项:
参数:

NSURL *appURL = [NSURL fileURLWithPath:@"file:///path/to/application.app"];
NSArray *fileURLs = [NSArray arrayWithObjects:[NSURL fileURLWithPath:@"file:///path/to/file1"],
                                              [NSURL fileURLWithPath:@"file:///path/to/file2"],
                                              nil];
NSError *err = nil;
BOOL success = [[NSWorkspace sharedWorkspace] openURLs:fileURLs withApplicationAtURL:appURL 
                                              options:0 configuration:NULL error:&err];

imageEditorPath.GetPlatformString().c_str()=“/Applications/Adobe Photoshop CC 2019/Adobe Photoshop CC 2019.app”-您可以这样做:
[[NSWorkspace sharedWorkspace]openFile:@”/Users/admin/q/177381.png”,其中应用程序:@“Adobe Photoshop CC 2019”]谢谢你,CJK。上面的例子非常简单。问题是当前的NSArray示例只包含一个参数,但我必须从一个可以包含2个或多个图像路径的向量中动态填充它。在这种情况下,您可以使用
openURL:WithApplicationaURL:options:configuration:error:
,为
选项:
配置:
传递
0
以使用标准默认值。[工作区启动应用程序url:url选项:0配置:0错误:&error];好的,但是如果配置:0如何获取函数参数NSArray??imageEditorPath.GetPlatformString().c_str()=“/Applications/Adobe Photoshop CC 2019/Adobe Photoshop CC 2019.app”-它工作得很好你可以这样做:
[[NSWorkspace sharedWorkspace]openFile:@”/Users/admin/q/177381.png”with application:@“Adobe Photoshop CC 2019”]谢谢你,CJK。上面的例子非常简单。问题是当前的NSArray示例只包含一个参数,但我必须从一个可以包含2个或多个图像路径的向量中动态填充它。在这种情况下,您可以使用
openURL:WithApplicationaURL:options:configuration:error:
,为
选项:
配置:
传递
0
以使用标准默认值。[工作区启动应用程序url:url选项:0配置:0错误:&error];好的,但是如果配置为0,如何获取函数参数NSArray??