Reputation: 17677
I have a UIDocumentPickerViewController
with the following code:
UIDocumentPickerViewController *documentPicker =
[[UIDocumentPickerViewController alloc] initWithDocumentTypes: @[@"public.text", @"public.sql"]
inMode: UIDocumentPickerModeOpen];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController: documentPicker
animated: YES
completion: nil];
This opens the picker and I can pick .txt files, but I cannot pick .sql files. The following screenshot shows what a .sql file looks like in the picker.
I've added the following to my info.plist
file which to my understanding may be needed (ignore the UTTypeReferenceURL, I'm just trying to get this to work.)
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.sql</string>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>SQL statement(s)</string>
<key>UTTypeIconFile</key>
<string>public.sql</string>
<key>UTTypeIdentifier</key>
<string>public.sql</string>
<key>UTTypeReferenceURL</key>
<string>http://www.w3.org/Graphics/JPEG/</string>
</dict>
</array>
What do I need to do to have UIDocumentPickerViewController
allow picking .sql file types?
Upvotes: 2
Views: 1305
Reputation: 17677
I was able to figure it out based on another question here. I added the following to my info.plist:
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>SQL statements</string>
<key>UTTypeIdentifier</key>
<string>com.hankinsoft.sqlpro.sql</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>sql</string>
</dict>
</dict>
</array>
And modified my UIDocumentPickerViewController
to be as follows:
UIDocumentPickerViewController *documentPicker =
[[UIDocumentPickerViewController alloc] initWithDocumentTypes: @[@"com.hankinsoft.sqlpro.sql"]
inMode: UIDocumentPickerModeOpen];
Upvotes: 1