2

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:

Greg
  • 34,042
  • 79
  • 253
  • 454

1 Answers1

5

You forgot to

import UniformTypeIdentifiers
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • I didn't do that and it still worked... I imported SwiftUI though, maybe that auto imports `UniformTypeIdentifiers`? – aheze Aug 17 '21 at 00:47
  • this worked - actually how is this - does Swift functions available for a class kind of dynamically change depending on what you have as import? – Greg Aug 17 '21 at 01:53
  • @Greg That new initializer expects a [`UTType`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype) which is not part of Foundation and/or UIKit. That's why you need to import UniformTypeIdentifiers framework. – Leo Dabus Aug 17 '21 at 02:18