我寫了一段 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所以帶入的參數值無法改變
想問問還有什麼方法能避開此錯誤