tags:

views:

396

answers:

1

I've only recently began using the debugger extensively, so I'm not sure if this is a limitation. When I debug on the iPhone, the variables aren't up to date unless I explicitly view it (ctrl click -> view variable as expression). Is there a way to view actual variables without viewing explicitly?

+1  A: 

Can you clarify your question? You should only be viewing data while the program is stopped -- examining data while it's running, if it works at all, is much less useful. Make sure to set a breakpoint, and then examine data once you've hit the breakpoint.

An alternative to using Xcode's built-in debugging features is to use the gdb console. Type ⌘-Shift-R, or select "Debugging Console" from the menu to open the console. Then, you can type commands like:

# View a variable
print var
# View this object's member variable
print self->memberVar
# Ask an Objective-C object to print itself:
print-object self

You should use print with primitive types (int, char*, etc.) and POD types (structs); you should use print-object with Objective-C objects (NSString, etc.). For more information about print and print-object, type

help print
help print-object

You can also use the abbreviations p and po for print and print-object respectively.

Adam Rosenfield
I was not aware of the console features you mentioned. Thank you. Clarification: I can see the variables but they don't reflect the current values. My breakpoint is set to pause when objects reach a certain position. After a few rounds, the variables still show the values at the beginning.
hyn