views:

211

answers:

3

I know how to do it for a float:

#define kMyConstant 1.0f

but how could I do that fora BOOL value?

+10  A: 

#define kMyConstantBOOL YES

Or

static BOOL MyConstantBool = YES;

Dave DeLong
I like the latter as you get some type checking and can view it and use it as a symbol in the debugger.
nall
agree except gdb/xcode understands #define.
Roger Nolan
did you mean "const" rather than "static"? static BOOL is a variable.
progrmr
+5  A: 

Here's an example:

#define kMyConstant      YES
#define kMyOtherConstant NO
Carl Norum
A: 

I would do it differently:

enum { MyConstantBool = YES };

It's a constant, it doesn't take up storage space.

progrmr