Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:44:42+00:00 2026-06-02T08:44:42+00:00

Just wondering – given that I have a typedef enum ‘color’ (and property of

  • 0

Just wondering – given that I have a typedef enum ‘color’ (and property of the same name) with a valid element ‘blue’, why is this ok:

 BOOL isBlue;

 if (color == blue){
     isBlue = YES;
 }

but this is not:

BOOL isBlue;

isBlue = (color == blue);

I’ve just started using enums so maybe i’m missing something simple?

Edit – as mentioned ‘blue’ is one of the valid elements of the enum, not a BOOL itself, i.e:

typedef enum { Blue, Red, Yellow } color;

and

@property color color;

Edit 2 – here’s my actual code, as requested. I’m a bit confused by the contradictory comments/answers. Should I expect this to compile (it doesn’t)?

.h

typedef enum { AddRecipes, ManageRecipes, RemoveRecipes } mode;

<snip>

@property mode mode;

.m

 @synthesize mode;

 <snip>

 BOOL modeIsAddRecipe = (mode == AddRecipes);

Edit 3 – for posterity I should mention that my error was trivial and unrelated. The discussion below proved enlightening though, many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:44:43+00:00Added an answer on June 2, 2026 at 8:44 am

    As @tia already told you, BOOL is defined as signed char, and YES and NO are defined as (BOOL)1 and (BOOL)0, respectively.

    It’s for that reason that both code samples you show in your question will work just fine. In the latter snippet, the equality expression evaluates to either 1 or 0. You can freely assign these integer values to a BOOL (signed char) value.

    The code will compile and run successfully, with neither an error nor a misbehavior.

    If you’re seeing something different, please edit your question to include your actual code and the error it produces, because the code you provided works just fine.

    Edit (now that you’ve provided the actual code): I think it should work, but it currently doesn’t (as of Xcode 4.3.1) because Clang is interpreting “mode” as the type mode, not the instance variable mode. If you rename the type to RecipeMode or change the expression to either explicitly reference the instance variable (self->mode) or use the property (self.mode), it compiles fine.

    So, congratulations. You’ve actually (in my opinion) found a compiler bug! I suggest reporting it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering what little scripts/programs people here have written that helps one with his
Just wondering. I have a page in Jquery Mobile which uses a popup that
Just wondering how I do this, Im creating a class that will have my
Just wondering, having the following simple code: var object1 = { name: function (){
Just wondering is it possible to build CLI app that can be run from
just wondering is there any chance that their will be a dummy database schemas
Just wondering how Cocos manages the CPU cycle and graphics engine for CCSprites that
Just wondering why something like this doesn't work: public function address($name){ if(!isset($this->addresses[$name])){ $address =
Just wondering how to set a hidden field value so that when I submit
Just wondering if what I want to do is possible with Solr: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.