测试应用程序是否可以打开特定类型?

发布于 2024-08-19 06:21:09 字数 236 浏览 18 评论 0原文

在 Mac OS X 上,如何判断给定应用程序是否打开特定类型?

我有两个我感兴趣的 UTI:public.text 和 public.image,并且我有一个应用程序列表。我想按这两种类型过滤列表,因此我有一个文本查看器列表和一个图像查看器列表。

我在 SO 上看到了一个相关问题,可以获取特定文档类型的所有查看者的列表。我可以这样做并获得集合的交集,但我宁愿能够单独询问每个应用程序。

有可可或碳的呼吁吗?

On Mac OS X, how can I tell if a given application opens a specific type?

I have two UTIs that I'm interested in: public.text and public.image and I have a list of applications. I want to filter the list by those two types so I have a list of text viewers and a list of image viewers.

I've seen a related question on SO where it's possible to get a list of all the viewers for a particular document type. I could do that and get the intersection of the set, but I'd rather be able to ask each application individually.

Are there any Cocoa or Carbon calls for that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡 2024-08-26 06:21:09

如果您想要给定文档类型的应用程序列表,请使用 LSCopyAllRoleHandlersForContentType

如果您想要特定应用程序的文档类型列表,请打开应用程序的 Info.plist 文件并阅读 CFBundleDocumentTypes 键。

If you want a list of applications for a given document type, use LSCopyAllRoleHandlersForContentType.

If you want a list of document types for a specific application, open the application's Info.plist file and read the CFBundleDocumentTypes key.

柠檬心 2024-08-26 06:21:09

启动服务是您的朋友。但我认为没有任何 API 可以获取给定应用程序支持的 UTI,因此不幸的是,我建议您使用您已经描述过的内容。

Launch Services is your friend. But I don't think there's any API which gets the UTIs supported by a given app, so I would suggest you to use what you already described, unfortunately.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文