Francesco
Francesco

Reputation: 87

Problem UIDocumentPickerViewController in iOS 14

sorry for the question but i can't find a solution or i can't understand ... until now I was using the function.

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        
        
         // Importo
         if controller.documentPickerMode == .import {
          
         my code
         }

       // Esporto
         if controller.documentPickerMode == .exportToService {
          may code
         }

now, .documentPickerMode in ios 14 is no longer present, how can I get the same result? or will he know if I come from import or export?

TKS

Upvotes: 1

Views: 798

Answers (1)

Leo Dabus
Leo Dabus

Reputation: 236558

Now you have to use four different methods. Two for exporting and another two for opening types of documents you specify:


Creates and returns a document picker that can export the types of documents you specify.

init(forExporting: [URL])

Creates and returns a document picker that can export or copy the types of documents you specify.

init(forExporting: [URL], asCopy: Bool)

Creates and returns a document picker that can open the types of documents you specify.

init(forOpeningContentTypes: [UTType])

Creates and returns a document picker that can open or copy the types of documents you specify.

init(forOpeningContentTypes: [UTType], asCopy: Bool)

Then you switch the controller when it gets called:

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {

    switch controller {
        case documentExporter:
            print("documentExporter")
        case documentImporter:
            print("documentImporter")
        default: break
    }

}

Upvotes: 1

Related Questions