objective-c - 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];
解决方案
CJK 的回答是正确的:[[NSWorkspace sharedWorkspace] openURLs:fileURLs withApplicationAtURL:appURL options:0 configuration:0 error:&err]; 其中 fileURLs 是要打开的文件数组,appURL 指向应用程序。– 中日韩语
CJK - 请作为答案发送。
推荐阅读
- javascript - 悬停时停止循环并显示相应的图像,鼠标移出时继续循环
- postgresql - PostgreSQL - 完整数据库中的可用空间
- vue.js - BootstrapVue - 在选择选项上使用工具提示?
- python - 用于报告的 PostgreSQL 和 Django 查询不起作用
- reactjs - 使用 usestate 数组时将复选框类型的 reactjs 输入元素限制为 2
- python - wxPython - 如何更改 ListCtrl 项目索引?
- animation - 用于扩展具有动态高度的单元格的 Swift UI 列表动画
- python - Python:随机执行没有随机内部参数的python函数
- jenkins - NotSerializableException 在 Jenkins 阶段结束时抛出
- java - 数据库中有空对象的Sqlite数据库