1

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

1 Answer 1

1

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
    }

}
Sign up to request clarification or add additional context in comments.

4 Comments

Hello, thanks for the answer ok but when the method documentPicker (_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL] is called when I click on the document to load, and then perform some operations, now how can I do?
just switch the controller and check which controller is calling the method.
Thanks for your time i put the switch in the but error notification method "Cannot find 'documentExporter' in scope"
@Francesco use the name of the controllers you have chosen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.