Objective-C: Comparing string with if() values doesnt work on [NSMutableArray objectatindex:]
You can't compare strings with ==
and !=
. Technically, that will just compare the pointers and not the values, which is what you want to do.
Instead you want something like:
if (! [yakitVal isEqualToString:@"LPG"]) {
Try using
if (![yakitVal isEqualToString:@"LPG"]){...}
to compare the string values, not == or !=.
EDIT: Negated the conditional.
Thank you guys for the answers, program is finally running as i wanted.
i also realized that my yakitval had a new line char at the end of it. so i've added this like to work
yakitVal = [yakitVal stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];