Reputation: 17687
I'm trying to use the iOS 14 initForOpeningContentTypes: rather than the deprecated initWithDocumentTypes:inMode:
and I'm unable to get access to files with the extension p8
(they are greyed out).
I'm trying the following code:
NSArray<UTType*> * contentTypes = @[[UTType typeWithFilenameExtension: @"p8"
conformingToType: UTTypeData]];
UIDocumentPickerViewController *documentPicker = nil;
documentPicker = [[UIDocumentPickerViewController alloc] initForOpeningContentTypes: contentTypes];
The picker launches, but the file "myfile.p8" is greyed out and unselectable. What am I doing wrong here?
Upvotes: 4
Views: 2057
Reputation: 326
Once I added the following to my application’s Info.plist I was able to select the file:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.my-company.my-identifier</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>My Description</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>p8</string>
</array>
</dict>
</dict>
</array>
Apparently it tells the system about the type. See this answer for info about UTExportedTypeDeclarations
.
Upvotes: 4