首页 > 解决方案 > NSURLComponents 中的 Swift 4 转义 & 符号

问题描述

我在 Swift 4 中使用 NSURLComponents,如下所示:

let urlComponents = NSURLComponents(string: webservice + "?PDFFile=" + PDFFile);

我的字符串 PDFFile 看起来像这样:

汤姆和简 PDF.pdf

我的问题是如何转义 NSURLComponents 中的 & 符号?

这就是我得到的:

ANC%2520%26%2520SHO%2520-%2520Laundry%2520Closets%2520to%2520be%2520Checked.pdf

但这就是我需要的:

ANC+%26+SHO+-+Laundry+Closets+to+be+Checked.pdf

标签: iosswift

解决方案


推荐阅读