18

I want to open UIDocumentPickerViewController and It should allow user to select all type of files. I tried to mention all UTIs in UIDocumentPickerViewController init method still couldnt find valid UTIs for some of files like rar,Visio files,mpp,mpt

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:[MingleUtils allowedUTIs] inMode:UIDocumentPickerModeImport];

and

+(NSArray*)allowedUTIs{
    return @[@"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"];
}
Murali
  • 1,869
  • 1
  • 14
  • 22

4 Answers4

33

If you want to allow any file type, you should use

UIDocumentPickerViewController* documentPicker = 
  [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"]
                                                         inMode:UIDocumentPickerModeImport];

See apple docs for UTI concepts

LaborEtArs
  • 1,938
  • 23
  • 27
13

Swift 5:

import MobileCoreServices

    let importMenu = UIDocumentPickerViewController(documentTypes: ["public.item"], in: .import)
    importMenu.delegate = self
    importMenu.modalPresentationStyle = .fullScreen
    self.present(importMenu, animated: true, completion: nil)
Mohammad Razipour
  • 3,643
  • 3
  • 29
  • 49
1

I think your best shot is to use abstract UTI types.

Using kUTTypeContent and kUTTypeItem should cover most of the file types.

Xarathor
  • 11
  • 3
1
UIDocumentPickerViewController* documentPicker = 
  [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.item"]
                                                         inMode:UIDocumentPickerModeImport];
niku
  • 472
  • 3
  • 12
  • 1
    Results in assertion error: Passed in type public.item doesn't conform to either public.content or public.data. If you are exporting a new type, please ensure that it conforms to an appropriate parent type. @"public.data" is correct. – mkirk Apr 20 '17 at 20:04