Skip to content

Instantly share code, notes, and snippets.

@olivaresf
Created August 31, 2020 05:29
Show Gist options
  • Save olivaresf/48d48199a7c8fa751b153177f3af90a0 to your computer and use it in GitHub Desktop.
Save olivaresf/48d48199a7c8fa751b153177f3af90a0 to your computer and use it in GitHub Desktop.
typedef NS_ENUM(NSUInteger, Degrees) {
DegreesCelsius,
DegreesFahrenheit,
DegreesKelvin,
};
- (NSString *)highestTemperatureForecasted:(WAForecastModel *)forecast degrees:(Degrees)type;
{
WADayForecast *dailyForecast = forecast.dailyForecasts.firstObject;
CGFloat temperature;
switch (type) {
case DegreesCelsius:
temperature = dailyForecast.celsius;
break;
case DegreesFahrenheit:
temperature = dailyForecast.fahrenheit;
break;
case DegreesKelvin:
temperature = dailyForecast.kelvin;
break;
default:
return @"BAD TYPE";
}
return [NSString stringWithFormat:@"%.0f°", temperature];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment