1

When debugging, I need to check the value of a private NSString member, named str for example. After:

    self.str = xxxxxxx;

I typed "po self.str" in the console but only got "(NSString *) $37 = 0x00000000 "
So I tried:

    NSLog("%@", self.str);

…then I saw the string value.

Why can’t I check the value of var using the command "po"?

Now I know it is because that I was using lldb as the debugger, as opposed to gdb. So the "po" (print-object) command can only display the address of pointer. Is there any solution about print an object's description while using lldb?

update: I find self itself is not available. I guess the problem has connection with the class instance, which is a static variable. Is that the reason po cannot find the pointer of self?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Gon
  • 1,135
  • 12
  • 22

1 Answers1

1

You need to call it like a method without the dot notation

po [self str]

alternatively if you know the backing vars name you can just print it directly

po _str
Paul.s
  • 38,494
  • 5
  • 70
  • 88
  • I saw the answer like what you said before and tried that. But both "po [self str]" and "po self.str" result in the same output"(NSString *) $37 = 0x00000000 ". – Gon May 23 '12 at 12:07
  • Are you letting the debugger actually go past the line where the assignment is made or are you stopping on the assignment? – Paul.s May 23 '12 at 12:14