-1

I am trying to NSLog a BOOL in Objective-C. When I do, it prints either as 0, 7, or -65. This is my code:

BOOL testBool;
NSLog(@"testBool = %i", testBool);

I've also tried %d and casting it as an int, but I get the same result every time. Can anyone think of why this would happen?

serverpunk
  • 10,665
  • 15
  • 61
  • 95

1 Answers1

0

Declaring it like this solved the problem:

BOOL testBool = NO;
serverpunk
  • 10,665
  • 15
  • 61
  • 95
  • 4
    Variables that are not initialized always potentially contain garbage. The only exception are instance variables which are automatically initialized to `0` or `nil` by the runtime. – omz Feb 06 '12 at 03:21