简体   繁体   中英

Decode file name from path (Swift 5)

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

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

Im get file name from path "Car%20Configurator.pdf" , but true name is "Car Configuration"

How can I'm decode name?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM