【发布时间】:2021-11-16 01:50:12
【问题描述】:
我需要创建一个带有大括号的查询参数的 URL。 这是一个例子。
https://samlpe.com/detail?item_code[]=smtwGBArkp3ByfrLK3KfxdoX
我尝试使用 URLComponents 和 URLQueryItem。但 URLQueryItem 不将数组(下面的["code"])作为值。
var urlComponents = URLComponents(url: URL(string: "https://samlpe.com/detail")!,
resolvingAgainstBaseURL: false)
urlComponents.queryItems = [URLQueryItem(name: "item_code", value: ["code"])]
有人对此有想法吗?
【问题讨论】:
-
@Alexander 我明白了,是的,它正在工作。谢谢!。
-
我把我的评论变成了一个你可以投票和接受的答案
标签: swift urlcomponents