如何查看状态码是否为200?
How to check the status code is whether 200 or not?
如何检查状态码是否为 200。我想用 swift 语言
session.dataTask(with: request){(data,response,error) in
if let response = response {
print(response)
}
}
let statusCode: Int? = {
if let httpUrlResponse = response as? HTTPURLResponse {
return httpUrlResponse.statusCode
}
return nil
}()
然后与200比较
如何检查状态码是否为 200。我想用 swift 语言
session.dataTask(with: request){(data,response,error) in
if let response = response {
print(response)
}
}
let statusCode: Int? = {
if let httpUrlResponse = response as? HTTPURLResponse {
return httpUrlResponse.statusCode
}
return nil
}()
然后与200比较