[Solved] Why dosn’t this objective-c if statement work? [closed]


you are using arithmetic operations on strings. that for sure makes no sense

create a float from the textfield input

if ([_label3.text floatValue] >= 20.0) {_label4.text = @"0";}

aslo you have to change the 1st and 2nd else branch, a the last one will never be called, as if it is true, the fist one is also be true.


float value = [_label3.text floatValue];

if (value > 20.0) {_label4.text = @"0";}
else if (value  <= 18.5) {_label4.text = @"2";}
else if (value < 20.0) {_label4.text = @"1";}

2

solved Why dosn’t this objective-c if statement work? [closed]