16

as in the title is there a way in Xcode to Add Watch or Inspect a code segment in Xcode

for example how can I see the result of [myObject aMethod] with actually stepping over or Stepping in.

0

2 Answers 2

22

To actually see the value change while you step through, you can right click the watch list of the debug area and choose "Add Expression..."

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

17

In the debugger console, if you stop at a breakpoint you can type po [myObject aMethod] to see the return value (if it's not an id type return value, use p ([return type here])[myObject aMethod]).

You can also set a breakpoint action to print something out without pausing, just right click to edit the breakpoint:

1 Comment

The reason you want a watch is usually that you want to step through and see it change, though. In other words, you want the breakpoint to stop. If you just want a lot of values in the console you can NSLog. A breakpoint that looks like a breakpoint but doesn't break at that point can be very confusing. Not a criticism towards your answer, since the asker wants what Apple doesn't provide and Apple provides confusing non-standard features.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.