我在解码时遇到问题。JSON
尝试获取日出和日落时间,但没有任何效果。帮助
func getData(latitude: String,longtitude: String) {
let url = URL(string: "https://api.sunrise-sunset.org/json?lat=\(latitude)&lng=\(longtitude)")
Alamofire.request(url!).responseJSON { (response) in
print(response)
guard let data = response.data else { return }
do {
let st = try JSONDecoder().decode(results.self, from: data)
print(st.sunrise)
}
catch {
print("error")
}
}
}