url为空格编码%20

时间:2017-01-31 04:32:05

标签: swift url-encoding

这已被问及并回答,但对于我的生活,我无法理解。

let encodedFileName = fileName?.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlPathAllowed)
let destinationURL = URL(fileURLWithPath: cachesDirectory.appendingFormat("/\(encodedFileName!)"))

生成一个具有以下名称的文件:

f95c3d5fa2064759fa4c397e7b8ab1e0_The2ame                   0f        0.000000e+002ind2p3

其他NSCharacterSet选项类似。我在这里失踪了什么?

我想要的只是%20代替空格。

0 个答案:

没有答案
相关问题