1

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

3 Answers 3

1

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.

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

Comments

1

Try something like this:

let picker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.png,UTType.jpeg, UTType.pdf],asCopy: true)

Comments

0

This worked for me:

let supportedTypes = [UTType.audio]
let picker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes)

Comments

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.