0

I am currently working on an app that shows the current weather. I get my response from openweathermap.org and in json. In the json response I receive all kinds of data concerning the weather; temperature, windSpeed, humidity and conditions.

What I want to do is interpret that data into text. For example I´m doing this now:

if [weater.temperature] <=-5.0f && [weather.humidity] <=80.0f && [weather.condition] isEqual:@"Snow") 

label setText....

The problem is that I have to repeat myself all the time and there a a lot of else ifs and also the statements exclude each other, for example if I want to have the label print something if it´s 5 degrees and 80& relative humidity and something else if the conditions are the same but it´s snowing.

Is there some other better solution to do this??

Pierre
  • 160
  • 2
  • 11

1 Answers1

-1

For the binary values (snowing/not snowing, rainy/not, etc.) I'd use enum with bitmasks and then bitwise OR/AND operations.

Check Declaring / comparing bitmasks

Community
  • 1
  • 1
Szymon Fortuna
  • 400
  • 1
  • 11