我正在尝试获取带有扩展名的选定文件名,UIDocumentPickerViewController
但文件名在文件扩展名的末尾有“]”。关于正确方法的任何建议?
这是我的代码:
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)
}