从路径解码文件名 (Swift 5)

Decode file name from path (Swift 5)

let FileName = ("\(urls[0])" as NSString).lastPathComponent

完整文件 url: file:///private/var/mobile/Containers/Data/Application/2BA0F976-0A79-43E8-B5E6-28A8F0AE4D63/tmp/vladKarlugin.Documents-Inbox/Car%20Configurator.pdf

我从路径 "Car%20Configurator.pdf" 获取文件名,但真实名称是 "Car Configuration"

我怎样才能解码名字?

创建一个URL,删除路径扩展并获取最后一个路径组件。

let fileName = URL(string: urls[0])!.deletingPathExtension().lastPathComponent