Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode 4 - watching values of custom variable during debug

I am new to xcode and I just have a quick question. In Visual Studio and Eclipse, I can add custom variables to a windows and watch its values during a debug session. I am looking for the same feature in Xcode 4, but I cannot find it. If it is possible in Xcode, could you please provide instruction so that I can do what I wish to do. If this is not possible, please let me know.

I am only able to find the window for variables that are "local", or "auto", or "all".

Thanks in advance.

like image 726
Daniel Nguyen Avatar asked Aug 12 '11 08:08

Daniel Nguyen


2 Answers

Right click in that same window (that has the toggles for Local, Auto, All) and click Add Expression. Type in the full expression and click Done. The new watch expression should show when debugging in the window in the lower left with an E next to it.

like image 87
Nathanial Woolls Avatar answered Oct 05 '22 10:10

Nathanial Woolls


Also, if you don't want to mess about with the IDE too much you can use gdb for this.

Click in the output window of the debugger and type po variable_name and it will print out the value of that variable at that time.

e.g

(gdb) po mArray

(gdb) __NSArray object1, object2 ... etc`

You can also use print variable_name to get the value of a variable.

like image 20
davbryn Avatar answered Oct 05 '22 09:10

davbryn