我是编程和Swift的新手。我正在浏览Alamofire的文档,并在以下代码块中找到了我不理解的代码声明:responseJSON { response in
。
Alamofire.request("https://httpbin.org/get").responseJSON { response in
print("Request: \(String(describing: response.request))") // original url request
print("Response: \(String(describing: response.response))") // http url response
print("Result: \(response.result)") // response serialization result
if let json = response.result.value {
print("JSON: \(json)") // serialized json response
}
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
print("Data: \(utf8Text)") // original server data as UTF8 string
}
}
Swift中究竟是什么意思?我理解它会发出请求并获取响应哪个正文以JSON格式返回,但我不确定{ response in
的含义。