这是罪魁祸首字符串和参数名= solsssㅗ
Alamofire.request(todoEndpoint)
.responseJSON { response in
// check for errors
guard response.result.error == nil else {
// got an error in getting the data, need to handle it
print("error calling GET on \(todoEndpoint)")
print(response.result.error!)
DispatchQueue.main.async
{
self.activityView.isHidden = true
self.activityView.stopAnimating()
}
return
}
所以我得到的URL错误总是无效的。如果我不带任何特殊字符就可以使用它。
答案 0 :(得分:1)
您可以尝试使用String url-
let urlWithSpecialCharacter = url.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed)