swift_Alamofire验证请求结果和可访问性
func manualValidation() {
Alamofire.request("http://mobile.weather.com.cn/data/forecast/101010100.html?_=1281891660081").validate(statusCode: 200..<300).validate(contentType: ["application/json","text/html"]).responseData { (response) in
switch response.result{
case .success:
print("成功")
case .failure(let error):
print("失败信息\(error.localizedDescription)")
}
}
}
func automaticValidation() {
Alamofire.request("http://mobile.weather.com.cn/data/forecast/101010100.html?_=1281891660081").validate().responseJSON { (response) in
switch response.result{
case .success:
print("成功")
case .failure(let error):
print("失败信息\(error.localizedDescription)")
}
}
}