OSX,无法使用自定义 UTI 进行 Finder 上下文菜单服务过滤
我需要在 Finder 应用程序中为自定义文件类型添加上下文菜单项。所以我使用 Apple Automator 创建了一项服务。当我在 NSSendFileTypes 中指定 public.data 时,上下文菜单项通常出现在所有类型的文件上,但当我使用应用程序 info.plist 中指定的 UTI 时,它不适用于定义的自定义文件类型。 任何人都可以帮助提示是否可以对 Finder 上下文菜单项服务使用自定义 UTI 过滤,如果是的话,我做错了什么,或者可能有任何“知道如何”?
这是我的服务工作流程文件的 info.plist 文件。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>MyService</string>
</dict>
<key>NSMessage</key>
<string>runWorkflowAsService</string>
<key>NSRequiredContext</key>
<dict>
<key>NSApplicationIdentifier</key>
<string>com.apple.finder</string>
</dict>
<key>NSSendFileTypes</key>
<array>
<string>com.myapp.anytype</string>
</array>
</dict>
</array>
</dict>
</plist>
这是我的应用程序 info.plist 中的 UTI 声明代码。
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.archive</string>
</array>
<key>UTTypeDescription</key>
<string>Any type file format</string>
<key>UTTypeIdentifier</key>
<string>com.myapp.anytype</string>
<key>UTTypeReferenceURL</key>
<string>http://myapp.com</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>anytype</string>
</array>
</dict>
</dict>
</array>
我可以在该类型文件的建议应用程序列表中看到我的应用程序,因此我认为声明是正确的。
I need to add a contextual menu item in Finder application for a custom file type. So I created a service using Apple Automator. When I specify for public.data in NSSendFileTypes context menu item appears normally on all type of files but when I use UTI specified in my application info.plist it doesn't work on defined custom file types.
Could any one help to hint whether it is possible to use custom UTI filtration for Finder context menu item service at all and if yes what am I doing wrong or there could be any "know how" ?
Here is my info.plist file of service workflow file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>MyService</string>
</dict>
<key>NSMessage</key>
<string>runWorkflowAsService</string>
<key>NSRequiredContext</key>
<dict>
<key>NSApplicationIdentifier</key>
<string>com.apple.finder</string>
</dict>
<key>NSSendFileTypes</key>
<array>
<string>com.myapp.anytype</string>
</array>
</dict>
</array>
</dict>
</plist>
Here is the UTI declaration code from my application's info.plist.
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.archive</string>
</array>
<key>UTTypeDescription</key>
<string>Any type file format</string>
<key>UTTypeIdentifier</key>
<string>com.myapp.anytype</string>
<key>UTTypeReferenceURL</key>
<string>http://myapp.com</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>anytype</string>
</array>
</dict>
</dict>
</array>
I can see my application in the list of suggested apps for that type of file, so I suppose the declaration is correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想分享我做错了什么。
我从应用程序导出的文件格式位于系统 UTI 列表中,因此无法导出该格式的 UTI 定义。我只是用了系统中声明的那个。
感谢选民!
Wanted to share what I did wrong.
The file format I was exporting from my app was in the list of system UTIs so my UTI definition for that format couldn't be exported. I just used the one declared in the system.
Thanks to voters!