通过UTI注册文件类型时出现问题 [英] Problem registering file type through UTIs

查看:282
本文介绍了通过UTI注册文件类型时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程式中使用 AquaticPrime 产生授权,而且开发人员指南建议我尝试注册自定义文件扩展名,以便用户可以简单地点击许可证,我的应用程序将打开它,然后可以验证许可证。

I'm using AquaticPrime for license generation in my app, and as the developer guide suggests I'm attempting to register a custom file extension, such that users can simply click on the license and my application will open it and can then verify the license.

为此,我向Info.plist添加了一个导出的UTI声明,如下所示:

To do this, I've added an exported UTI declaration to my Info.plist as follows:

<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeDescription</key>
        <string>MyApp License File</string>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.xml</string>
        </array>
        <key>UTTypeIdentifier</key>
        <string>com.mycompany.myapplicense</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>myapplicense</string>
            </array>
        </dict>
    </dict>
</array>

但是,当我双击具有该扩展名的文件时, MyApp也不会作为推荐的应用程序之一打开文件类型。此外,当查看文件的信息面板时,不会显示上面指定的文件类型描述。

However, when I double-click on a file with that extension it doesn't open in MyApp, and nor does MyApp appear as one of the recommended apps to open the file type with. As well, when viewing the Info panel for the file, the filetype description as specified above doesn't appear.

任何人都可以看到我的UTI声明有任何问题,还是有其他我错过的东西?

Can anyone see anything wrong with my UTI declaration, or is there something else that I've missed?

感谢

推荐答案

您还需要一个 CFBundleDocumentTypes 声明。 >

You also need a CFBundleDocumentTypes declaration.

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFile</key>
        <string>MyAppLicenseIcon</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>NSDocumentClass</key>
        <string>MyAppLicenseHandler</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.mycompany.myapplicense</string>
        </array>
    </dict>
</array>

这篇关于通过UTI注册文件类型时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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