I need to allow ppt,docx, xlsx and pdf files only to be picked up by document picker in my application. What I need to set as document types when I initialize my document picker?
Asked
Active
Viewed 519 times
1 Answers
1
I have added couple of types in the below mentioned code, please check if it solves your issue:
let types: [String] = [kUTTypePDF as String,kUTTypeSpreadsheet as String, kUTTypePresentation as String, "com.apple.iwork.pages.pages", "public.text"]
let documentPicker = UIDocumentPickerViewController(documentTypes: types, in: .import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: nil)
.
Other available types which you can try:
"com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers", "com.apple.iwork.keynote.key","public.image", "com.apple.application", "public.item","public.data", "public.content", "public.audiovisual-content", "public.movie", "public.audiovisual-content", "public.video", "public.audio", "public.text", "public.data", "public.zip-archive", "com.pkware.zip-archive", "public.composite-content", "public.text", " "com.microsoft.word.doc"
Please comment if you have any question.
Happy to help!

Mohit Kumar
- 2,898
- 3
- 21
- 34
-
@Nikhil Gupta please mark this answer as accpeted if this solves your issue. Thanks! – Mohit Kumar Apr 09 '20 at 16:36
-
Thanks this help. Just an update that I used "com.microsoft.word.doc" for word documents. – Nikhil Gupta Apr 14 '20 at 17:26
-
Thanks, I have updated the post for com.microsoft.word.doc – Mohit Kumar Apr 15 '20 at 05:20