Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- URLSession.shared.dataTask(with: URL(string: "https://api.openweathermap.org/data/2.5/weather?q=(city),(countryCode)&appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxx”)!) { data, response, error in
- if let error = error {
- print("Error:n(error)")
- } else {
- do {
- let weather = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String: AnyObject]
- self.weatherLabel.stringValue = "Temperature (weather["main"]!["temp"]!!)°CnHumidity (weather["main"]!["humidity"]!!)%nPressure (weather["main"]!["pressure"]!!)hPa."
- }
- catch let jsonError as NSError {
- print("JSON error:n(jsonError.description)")
- }
- }
- }.resume()
Add Comment
Please, Sign In to add comment