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

Posted on 2012-09-06
Last Modified: 2012-09-06
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
Question by:rmmarsh
    LVL 14

    Expert Comment

    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).
    LVL 74

    Accepted Solution

    Are you sure the == operator works for string comparisons? A quick search shows the use of isEqualToString function.

    Author Closing Comment

    Thank you, thank you, thank you!  I have spent over 2.5 hours on this, and you hit it on the head!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now