你能动态分配CFBundleDocumentTypes到你的Cocoa应用程序吗? [英] Can you dynamically assign CFBundleDocumentTypes to your Cocoa application?

查看:304
本文介绍了你能动态分配CFBundleDocumentTypes到你的Cocoa应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以动态分配CFBundleDocumentTypes到您的Cocoa应用程式吗?在运行时期间的含义可以为我的应用程序分配更多的扩展来处理。

Can you dynamically assign CFBundleDocumentTypes to your Cocoa application? Meaning during run time can I assign more extensions for my app to handle.

目前,我为应用程序设置了一些扩展,以便在Info.plist中使用CFBundleDocumentTypes来处理,但是我想在应用程序执行期间通过代码执行此操作时间)。基本上我可以让Launch Services知道新的扩展而不修改Info.plist文件。

Currently I set some extensions for my app to handle using CFBundleDocumentTypes in the Info.plist, but I would like to do this through code while the application is executing (during run time). Basically can I make Launch Services aware of new extensions without modifying the Info.plist file.

谢谢。

推荐答案

目前,没有公共API 1 ,用于在运行时期间通过Launch Services动态(取消)注册文档类型。

At the moment, there’s no public API1 for an application to dynamically (un)register document types with Launch Services during runtime.

Open Emu 面临这个问题。用户可以选择性地下载/安装模拟器,这些模块是Info.plist文件定义文档类型的捆绑包。在安装仿真器时,捆绑中定义的类型需要是应用程序 Info.plist中定义的类型的一部分。打开Emu重写应用程序Info.plist,以便执行此操作 - 请参阅 -updateInfoPlist in OEGameDocumentController

Open Emu faces this very problem. Users are able to selectively download/install emulators, which are bundles whose Info.plist files define document types. Upon installing an emulator, the types defined in the bundle need to be part of the types as defined in the application Info.plist. Open Emu rewrites the application Info.plist in order to do so — see -updateInfoPlist in OEGameDocumentController.

请注意,覆盖信息包Info.plist违反了Mac App Store的政策。

Note that overwriting the bundle Info.plist is a violation of Mac App Store’s policy.

我们已提交了雷达,要求对文档类型进行运行时(未)注册。我建议您另外提交一个文件,该文件应该与#2526726 重复关闭。即使它是一个重复,重要的是提交它,使苹果有一个人需要这个功能的数量的估计。

We have filed radars asking for runtime (un)registration of document types. I suggest you file another one, too, which should be closed as a duplicate of #2526726. Even if it’s a duplicate, it’s important to file it anyway so that Apple have an estimate of the number of people that need this feature.

1 但是可能通过SPI。当我查看这个,我偶然发现 _LSRegisterItemFromItemInfo()在启动服务。

1It might be possible via SPI, though. When I was looking into this, I stumbled upon _LSRegisterItemFromItemInfo() in Launch Services.

这篇关于你能动态分配CFBundleDocumentTypes到你的Cocoa应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆