how to initalise UIDocumentPickerViewController noting "forOpeningContentTypes" (from doco) seems to be deprecated in IOS?

600 views Asked by At

When following the onsite IOS documentation for UIDocumentPickerViewController in Xcode 12.5.1 with IOS 14.5 deployment target I get an error:

Incorrect argument label in call (have 'forOpeningContentTypes:', expected 'forExporting:')

Any advice on how the usage of thie IOS UIDocumentPickerViewController is supposed to be used now?

My Code Except:

// Create a document picker for directories.
let documentPicker =
    UIDocumentPickerViewController(forOpeningContentTypes: [.folder])
documentPicker.delegate = self

Snapshot of error:

enter image description here

Documentation for how to use document picker here:

https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories gives:

1

There are 1 answers

3
matt On BEST ANSWER

You forgot to

import UniformTypeIdentifiers