Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

register a custom file type in iOS

I'm working on iOS application in which i want XML file to be the main input for this application.I've started a search trip (mainly in stackoverflow)to find how can i receive XML files from the Email.

first I've found an alternative method which was registering URL format for my files and use it in the Email instead of the file attached and this method works good.

now I want to use the file itself (attached) I found that i need to register a custom file type in this application depend on this resources

  1. apple reference
  2. stackoverflow question
  3. stackoverflow question 2

related to this I've edited the info.plist file with this code

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>XML File</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.IT.parseXML.XML</string>
        </array>
    </dict>
</array>

and this part also

<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.text</string>
        </array>
        <key>UTTypeDescription</key>
        <string>XML Document</string>
        <key>UTTypeIdentifier</key>
        <string>public.xml</string>
        <key>UTTypeReferenceURL</key>
        <string>http://www.w3.org/TR/rec-xml</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>xml</string>
            </array>
            <key>public.mime-type</key>
            <string>text/xml</string>
        </dict>
    </dict>
</array>

what I expect is to be able to handle XML files from emails... but this doesn't happen, what I'm missing ??

thanks in advance

like image 608
OXXY Avatar asked Oct 17 '11 10:10

OXXY


1 Answers

I've figured out the problem in my configuration it was on this line

<key>LSItemContentTypes</key>
    <array>
        <string>com.IT.parseXML.XML</string>
    </array>

it should be

<key>LSItemContentTypes</key>
    <array>
        <string>public.XML</string>
    </array>

as it is in the public identifier

like image 171
OXXY Avatar answered Sep 19 '22 10:09

OXXY