Xcode evaluating expressions while debugging

Christopher Martin picture Christopher Martin · Jan 28, 2011 · Viewed 34.3k times · Source

I am working on an iPhone app. I am a full-time Java developer and I am used to using Eclipse where I can put a breakpoint in and stop the process. Then, I can type in any expression that I want and Eclipse will evaluate it using the values from that point in the process.

Is there a way to do that in Xcode? I want to be able to stop at a breakpoint and then enter some code to evaluate it. The gdb console will let me do po (print-object), but it is really limited. Any help?

Answer

Belden Fox picture Belden Fox · Mar 28, 2013

In XCode 4.0 this is sort of hidden in the GUI. When you're at a breakpoint you can probably see the Variables View inside the Debug Area; it's the pane which shows local variables and such. Right-click on the Variables View and select "Add Expression..."

I realize this is an old thread but it's still a top Google hit so I thought it worth answering.