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?
Use the po command in the Debug area Set up a breakpoint on the relevant area of code, then when the program stops at the breakpoint, enter commands in the Console in the Debug Area. The relevant command is po (print object) followed by the expression you want to evaluate.
Click the disclosure triangles to explore instance variables for classes and structures, or internals for other data types. Select a variable and click the Quick Look button to see a preview of the variable, click the Print Description button to print a description of the object in the console.
You can click on Breakpoint Navigator and click on + symbol at the bottom and select Symbolic Breakpoint as an option. Now, you can ask - This is fine for putting a break on simple variables.
When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.
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.
My practice:
po [NSUserDefaults standardUserDefaults]
displays: <NSUserDefaults: 0x6143040>
po [[NSUserDefaults standardUserDefaults] stringForKey:@"Currency"]
displays: "CHF"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With