Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialise UIDocumentPickerViewController with all type of UTIs

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"];
}
like image 990
Murali Avatar asked Oct 13 '15 10:10

Murali


3 Answers

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

like image 128
LaborEtArs Avatar answered Oct 14 '22 08:10

LaborEtArs


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)
like image 13
Mohammad Razipour Avatar answered Oct 14 '22 07:10

Mohammad Razipour


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

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

like image 1
Xarathor Avatar answered Oct 14 '22 07:10

Xarathor