我写了一段 http get程式
画~~~~~的地方会出现used within its own initial value的错误
func get(urlString: String,parameters: Any?,
success:@escaping (URLSessionDataTask,Any) -> (),
failure:@escaping (URLSessionDataTask,NSError) -> ())
{
if let url = URL(string:urlString) {
let task = URLSession.shared.dataTask(with: url) {
(data, response, error) in
if error != nil
{
failure(task,error)
~~~~~~~~~~~~~~~~~~~~
} else {
success(task,response)
~~~~~~~~~~~~~~~~~~~~~~
}
}.resume()
}
}
因为需要兼容以前使用AFNetworking的code所以带入的参数值无法改变
想问问还有什么方法能避开此错误