Skip to content

Instantly share code, notes, and snippets.

@Pasanpr
Created May 2, 2016 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pasanpr/734884cb421cf904bb7f1c7d433bbf39 to your computer and use it in GitHub Desktop.
Save Pasanpr/734884cb421cf904bb7f1c7d433bbf39 to your computer and use it in GitHub Desktop.
extension CurrentWeather: JSONDecodable {
init?(JSON: [String : AnyObject]) {
guard let temperature = JSON["temperature"] as? Double,
humidity = JSON["humidity"] as? Double,
precipitationProbability = JSON["precipProbability"] as? Double,
summary = JSON["summary"] as? String,
iconString = JSON["icon"] as? String else {
return nil
}
let icon = WeatherIcon(rawValue: iconString).image
self.temperature = temperature
self.humidity = humidity
self.precipitationProbability = precipitationProbability
self.summary = summary
self.icon = icon
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment