-
-
Save Pasanpr/19a456790bda4e9972aa3e1ea3d6fa8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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