daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. URLSession.shared.dataTask(with: URL(string: "https://api.openweathermap.org/data/2.5/weather?q=(city),(countryCode)&appid=xxxxxxxxxxxxxxxxxxxxxxxxxxxx”)!) { data, response, error in
  2.       if let error = error {
  3.            print("Error:n(error)")
  4.     } else {
  5.            do {
  6.                 let weather = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String: AnyObject]
  7.                 self.weatherLabel.stringValue = "Temperature (weather["main"]!["temp"]!!)°CnHumidity (weather["main"]!["humidity"]!!)%nPressure (weather["main"]!["pressure"]!!)hPa."
  8.         }
  9.            catch let jsonError as NSError {
  10.                 print("JSON error:n(jsonError.description)")
  11.         }
  12.     }
  13. }.resume()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top