I'm trying to get the selected filename with extension from UIDocumentPickerViewController
but the filename has "]" at the end of the file extension. Any suggestion on what is the correct way?
Here is my code:
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
let filename = URL(fileURLWithPath: String(describing:urls)).lastPathComponent // print: myfile.pdf]
self.pickedFile.append(filename)
// display picked file in a view
self.dismiss(animated: true, completion: nil)
}