Reputation: 866
I am developing a swiftUI iOS 13+ application and I ran into a warning while developing a UIViewRepresentable for document picking.
According to the apple dev doc the initialiser of UIDocumentPickerViewController will be deprecated in future releases so this line:
let picker = UIDocumentPickerViewController(documentTypes: [kUTTypePDF as String], in: .open)
promts a deprecation warning and I have troubles finding a replacement. Can somebody help me ?
thanks
Upvotes: 1
Views: 2611
Reputation: 545
This worked for me:
let supportedTypes = [UTType.audio]
let picker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes)
Upvotes: 0
Reputation: 471
Try something like this:
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.png,UTType.jpeg, UTType.pdf],asCopy: true)
Upvotes: 1
Reputation: 866
While asking the question I noticed there was other initialisers to this class. I ended up just using the :
UIDocumentPickerViewControllerinit(forOpeningContentTypes: [UTType])
convenience initializer
I let this answer here since the function just became deprecated and no google search showed any answers less than a year old.
Upvotes: 1