What's wrong with this statement? (objective-c, a superset of C)

what's wrong with this statement? sysLangCode is equal to "ja"... statement fails and executes the "else" statements

if(sysLangCode == @"en" ||
sysLangCode == @"de" ||
sysLangCode == @"it" ||
sysLangCode == @"es" ||
sysLangCode == @"fr" ||
sysLangCode == @"ja" ||
sysLangCode == @"zh-Hant") {
    statements to be executed if true
}
else {
   exec if false
}
rmmarshAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
Are you sure the == operator works for string comparisons? A quick search shows the use of isEqualToString function.
0
 
theras2000Commented:
Based on my previous knowledge and some forums I just googled, I think you need to nest these conditions in multiple if statements like
if (sysLanCode == a)
  if (sysLanCode == b) etc. etc.

An if statement is looking for a single result of TRUE or FALSE; 1 or 0.
Currently your if statement is computing as if (0 or 0 or 0 or 0 or 1 or 0 or 0) which it doesn't understand.  You need it to simply qualify as if(1) or if(0).
0
 
rmmarshAuthor Commented:
Thank you, thank you, thank you!  I have spent over 2.5 hours on this, and you hit it on the head!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.