1

After running these two lines in Xcode 4.6.3, both x and y are marked as (null) with grey text in the debugger’s Variables View pane.

  NSNumber* y = [NSNumber numberWithBool:YES];
  NSNumber* z = [NSNumber numberWithBool:NO];

Ditto for:

  NSNumber* literalYes = @YES;
  NSNumber* literalNo = @NO;

Yet if I context-click on those items in the Variables View pane, and from the context menu choose Print Description, I do see the correct 1 or 0 value.

Why does the debugger’s Variables View pane report these objects as null when they are not?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • 7
    Do not trust the variables view. Better print the value/description of the variable from the debug console or right click it in the variables view and print it from there. – Hermann Klecker Sep 11 '13 at 08:20
  • set breakpoint after this code and make "po y" + enter (this is print object command) in your debugger console view and make sure, I believe it's actually cannot be null – iiFreeman Sep 11 '13 at 09:44
  • This may help you: http://stackoverflow.com/questions/753153/xcode-debugging-view-value-of-nsnumber – lykant Sep 11 '13 at 10:52
  • If you are running in Release mode you wont be able to see variables value in left pane. – GoodSp33d Apr 21 '14 at 08:43

1 Answers1

1

Xcode 4 debugger lies. (See comment above by Herrman Klecker)

Ignore the grey color text "(null)".

Look at this question, Xcode debugging: View value of NSNumber?, for tips on displaying actual values.

One way… Set breakpoint after your code, click into the debugger Console View, and use the Print Object command by typing po y. Press Return/Enter to execute the expression and see resulting value in the console. The commands p and po work in both the older gdb and newer lldb debugger technologies. See Debugging tips for Objective-C programming for examples.

Another way… Open the Debugger view and in the Summary column enter something like: {(int)[$VAR intValue]}

Community
  • 1
  • 1
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154