ios - 如何在 iOS 7 中将 CSV 文件关联到我的应用程序

标签 ios csv plist

大家好。

我逐行学习了这两个教程,尝试将我的应用程序关联到 csv 文件(电子邮件应用程序附件),但是在我将这些更改添加到我的应用程序的 plist 文件之后,然后构建我的应用程序并运行它设备(iPhone 4,iOS 7.0.4),没有任何反应,我的意思是当我点击电子邮件中的 .csv 文件时,我的应用程序仍然没有出现在打开的可用应用程序列表中,我只是不知道我在哪里做错了,或者 iOS 7 有不同的方式来做这件事?

http://blog.spritebandits.com/2011/12/14/importing-csv-data-file-into-an-ios-app-via-email-attachment/

http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app

这是我的 plist 更改(教程后添加的新条目)的样子:

enter image description here

这是应用程序设置屏幕:

enter image description here

这是 xml 版本:

        <key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeName</key>
                <string>CSV Document</string>
                <key>LSHandlerRank</key>
                <string>Owner</string>
                <key>CFBundleTypeRole</key>
                <string>Viewer</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string></string>
                </array>
            </dict>
        </array>
        <key>UTExportedTypeDeclarations</key>
        <array>
            <dict>
                <key>UTTypeDescription</key>
                <string>CSV Document</string>
                <key>UTTypeConformsTo</key>
                <array>
                    <string>public.data</string>
                </array>
                <key>UTTypeIdentifier</key>
                <string>Damian-s.${PRODUCT_NAME:rfc1034identifier}</string>
                <key>UTTypeTagSpecification</key>
                <dict>
                    <key>public.filename-extension</key>
                    <string>csv</string>
                    <key>public.mime-type</key>
                    <string>application/inventorytodo</string>
                </dict>
            </dict>
        </array>

最佳答案

您在 CFBundleDocumentTypes 定义中缺少 UTI 类型:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>CSV Document</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string></string>
        </array>
    </dict>
</array>

应该是:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>CSV Document</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>Damian-s.${PRODUCT_NAME:rfc1034identifier}</string>
        </array>
    </dict>
</array>

关于ios - 如何在 iOS 7 中将 CSV 文件关联到我的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22967013/

相关文章:

ios - Swift:在 Objective C 类中设置一个 NSString 属性

ios - 使用 Storyboard在 CollectionView 中仅显示两列,多行

php - 在php中下载csv错误

excel - 自动保存附件 Outlook 转换为 csv

iphone - 编辑应用程序的 .plist 文件

ios - 当应用程序在后台运行时,freestreamer无法在通话结束后继续播放音乐(实际上没有声音)

ios - 当使用手势关闭呈现的 View Controller 时如何获得通知?

excel - Google 文档导出带双引号的 CSV

ios - 将文件添加到我的 Plist - 我想我已经快到了

iphone - iOS更新之间的常数会保持不变吗?