My document-based UIKit app can open plain text files such as .txt files.
When tapping a particular button I want to be able to select a folder, but when using the code below, the document picker allows me to select folders as well as .txt files:
class DocumentViewController: UIDocumentViewController, UIDocumentPickerDelegate {
override func viewDidAppear(_ animated: Bool) {
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
documentPicker.delegate = self
present(documentPicker, animated: true)
}
}
If I remove the text file entry from the Info.plist's document types list, it works as expected. Is this a bug and if yes, is there a workaround?
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Text</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>public.text</string>
</array>
</dict>
</array>
I created FB22254960.