Skip to content

Instantly share code, notes, and snippets.

@Pasanpr
Created May 2, 2016 20:06
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/19a456790bda4e9972aa3e1ea3d6fa8c to your computer and use it in GitHub Desktop.
Save Pasanpr/19a456790bda4e9972aa3e1ea3d6fa8c to your computer and use it in GitHub Desktop.
enum WeatherIcon: String {
case ClearDay = "clear-day"
case ClearNight = "clear-night"
case Rain = "rain"
case Snow = "snow"
case Sleet = "sleet"
case Wind = "wind"
case Fog = "fog"
case Cloudy = "cloudy"
case PartlyCloudyDay = "partly-cloudy-day"
case PartlyCloudyNight = "partly-cloudy-night"
case UnexpectedType = "default"
init(rawValue: String) {
switch rawValue {
case "clear-day": self = .ClearDay
case "clear-night": self = .ClearNight
case "rain": self = .Rain
case "snow": self = .Snow
case "sleet": self = .Sleet
case "wind": self = .Wind
case "fog": self = .Fog
case "cloudy": self = .Cloudy
case "partly-cloudy-day": self = .PartlyCloudyDay
case "partly-cloudy-night": self = .PartlyCloudyNight
default: self = .UnexpectedType
}
}
}
extension WeatherIcon {
var image: UIImage {
return UIImage(named: self.rawValue)!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment