如何将文件类型.x_t与iOS App关联?

时间:2015-02-20 13:50:43

标签: ios iphone

我想将具有特定扩展名的文件与iOS App相关联。我已成功使用链接关联其他文件类型,如.obj,.stl等。 How do I associate file types with an iPhone application?

但是对于在扩展名中带有“_”下划线的文件无法关联。扩展名为.x_t

的文件失败

Apple UTI指南说明了这一点 https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-CHDHIJDE

  

UTI字符集统一类型标识符是Unicode字符串   通常包含ASCII字符集中的字符。然而,   只允许使用ASCII字符的子集。你可以使用   大写和小写的罗马字母(A-Z,a-z),数字0   通过9,点(“。”)和连字符(“ - ”)。这个限制是   基于DNS名称限制,在RFC 1035中规定。

     

统一类型标识符也可以包含任何Unicode   字符大于U + 007F。

     

重要提示:UTI字符串中出现的任何非法字符   例如,下划线(“_”),冒号(“:”)或空格(“”) - 将导致   要作为无效UTI拒绝的字符串。在API层,没有错误   为无效的UTI生成。

那么有没有办法将x_t文件与iOS App相关联?

1 个答案:

答案 0 :(得分:0)

将UTI用作com.you.x-t,将文件扩展名用作x_t。

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
        </array>
        <key>CFBundleTypeName</key>
        <string>x_t file</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.you.x-t</string>
        </array>
    </dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.item</string>
        </array>
        <key>UTTypeDescription</key>
        <string>x_t files</string>
        <key>UTTypeIdentifier</key>
        <string>com.you.x-t</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>x_t</string>
        </dict>
    </dict>
</array>

UTI:com.you.x_t&amp;文件扩展名x_t不起作用

UTI:com.you.x-t&amp;文件扩展名x-t不起作用

相关问题