Answer the question
In order to leave comments, you need to log in
How to get data from weather? icon and description with SwiftyJSON?
Here is JSON , you need to get the description and icon fields from weather, but it still doesn’t work.
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
let checkString = searchBar.text!.replacingOccurrences(of: " ", with: "%20")
let url = URL(string: "http://api.openweathermap.org/data/2.5/weather?q=\(checkString),&appid=b9be245f75c83dbb63d7700aa9e6f98e")!
do {
let jsonResult = try Data(contentsOf: url)
let json = JSON(jsonResult)
let city = json["name"].stringValue
// let temp = json["main"]["temp"].intValue
let weather = json["weather"][0]["description"].stringValue
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question