[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

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
1 Solution
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).
käµfm³d 👽Commented:
Are you sure the == operator works for string comparisons? A quick search shows the use of isEqualToString function.
rmmarshAuthor Commented:
Thank you, thank you, thank you!  I have spent over 2.5 hours on this, and you hit it on the head!

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now