Search code examples
pdfswift3uidocumentpickervc

Allow only images & pdf in UiDocument Picker Swift 3


I need the user to select only images and pdf files from UIDocumentPicker & want to check which type of file user has selected in the DocumentPicker delegate method

I have used this but this allow everything

let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.content","public.data"], in: .import)

Solution

  • You can use

    let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.composite-content"], in: .import)
    

    this will only allow pdf files to import