hyn
hyn

Reputation: 473

iPhone debugging: variables are not up to date?

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?

Upvotes: 0

Views: 595

Answers (1)

Adam Rosenfield
Adam Rosenfield

Reputation: 400274

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.

Upvotes: 1

Related Questions