如何检查状态码是否为200。我想用快速的语言来做
session.dataTask(with: request){(data,response,error) in
if let response = response {
print(response)
}
}
答案 0 :(得分:0)
let statusCode: Int? = {
if let httpUrlResponse = response as? HTTPURLResponse {
return httpUrlResponse.statusCode
}
return nil
}()
然后将其与200进行比较