本文介绍了对"urlComponents"的访问重叠,但修改需要排他访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在iOS 11和Swift 4上使用Lyft API,并且在第二行收到错误
I am trying to use the Lyft API with iOS 11 and Swift 4, and am receiving an error on the second line, which is
我不确定这意味着什么,以及如何解决它.感谢您的任何帮助,谢谢!
I am unsure what this means, and how I can get around it. Any help is appreciated, thanks!
let queryItems = parameters
.sorted { $0.0 < $1.0 }
.flatMap { components(forKey: $0, value: $1) }
var urlComponents = URLComponents(url: mutableURLRequest.url!, resolvingAgainstBaseURL: false)
urlComponents?.queryItems = (urlComponents?.queryItems ?? []) + queryItems //error here
推荐答案
我想您需要先将其设置为局部变量,然后再对其进行更改,请尝试以下操作:
I guess you need to set first to a local variable and then change it , try this:
var urlComponents = URLComponents(url: mutableURLRequest.url!, resolvingAgainstBaseURL: false)
var localVariable = urlComponents
urlComponents?.queryItems = (localVariable?.queryItems ?? []) + queryItems
这篇关于对"urlComponents"的访问重叠,但修改需要排他访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!