我收到了一个错误:"额外的争论'进展'在电话"当我在Swift中使用AFNetworking时

时间:2017-12-11 15:30:06

标签: ios swift afnetworking

我试图在Swift中使用$sqlquery = "INSERT INTO maker_form_details(caseid,nom,address,date,no_de_tel,quest_no,lieu_interview,tom,mainbank,netscore,overallsatisfaction,q12_comment,q13_probablite,q14_comment,q15_recommendation,q16_sarisfaction,q17_temps,q19,q20Bancassurance,Mobhile_Banking,q21ameliorer) values ($id,'$Name','$address','$date',$tel,'$quest','$lieu','$tom','$mainbank',$netscore,$overallsatisfaction,'$question12','$question13','$question14',$question15,$question16,$question17,'$question19','$question20p1','$question20p2','$question21')"; $resultquery = sqlsrv_query($conn, $sqlquery); if(!$resultquery){ print_r(sqlsrv_errors()); } ,我的代码是:

AFNetworking

然后编译器抛出错误:

  

额外参数' self.get(urlString, parameters: parameters, progress: { (progress: Progress) in print(progress) }, success: { (task: URLSessionDataTask, result: AnyObject) in print(result) }) { (task: URLSessionDataTask, error: Error) in print(error) } '在电话中。

我尝试将progress分配给它,但错误仍然存​​在 如果我不想改为Alamofire,我该怎么办?

1 个答案:

答案 0 :(得分:0)

您的代码中存在多种类型不匹配(URLSessionDataTask而不是URLSessionDataTask?AnyObject而非Any?等。

你可以轻松摆脱这些,因为闭包不需要在Swift中拥有外部类型说明符。删除所有这些实例,例如: Progress: URLSessionDataTask ...

self.get(urlString, parameters: parameters, progress: { (progress) in
    print(progress)
}, success: { (task, result) in
    print(result)
}) { (task, error) in
    print(error)
}

Read more about Swift closure syntax here.