views:

260

answers:

1

Hello , What is the default value of BOOL in Objective-C?

+8  A: 

There is no default value if you write

-(void)somemethod {
  BOOL x;  // <--- no default value

It is initialized to garbage.

However, for a BOOL ivar, it will be initialized to NO, as the whole instance is filled with 0 on initialization.

KennyTM
Can you count on the non ivar BOOL to always be the same garbage? or is it different? (ie. I'm seeing it evaluate to the integer value of '2' in a NSlog statement)
bentford
@bentford: No you can't.
KennyTM