这给出了一个错误:"转义关闭只能捕获..."
我该如何解决?
func check_info(tag: String, info: String, code: inout Int) {
Alamofire.request(
URL + "/api/test_information/",
method: .post,
parameters: [tag: info],
encoding: JSONEncoding.default
).responseString { response in
code = (response.response?.statusCode)!
}
}
答案 0 :(得分:0)
已编辑:如果要返回状态代码,请使用此回调函数。回调后,您会在收到回复后立即返回状态代码。
func check_info(tag: String, info: String, statusCode: @escaping (String)->Void){
Alamofire.request(URL + "/api/test_information/", method: .post, parameters: [tag: info], encoding: JSONEncoding.default).responseJSON { response in
statusCode((response.response?.statusCode)!)
}
}
要打电话,请使用:
check_info(tag: "yourtag", info: "yourInfo){
statusCode in
print(statusCode)
}