user4951
user4951

Reputation: 33130

Watch Expression in Xcode

Say I am debugging. Say I need to know what the value of [somevariable count]

How would I do so?

Upvotes: 7

Views: 8854

Answers (2)

Elad Lavi
Elad Lavi

Reputation: 1381

Put a breakpoint on the relevant code line. When Xcode stops on that line, in the debug area (the bottom of the screen is splitted to two parts, look at the right one, if you don't see the bottom part, shift+cmd+Y, plus sometimes the right side or the left side are hidden and there are small buttons on the right bottom side to show them), you see all of the local and global variables. Right click (or two fingers) that debug area, and you will see a context menu with one of the options "add expression". Type in your expression.

Note: above previous user's comment about the word "watch" is pretty clear to whomever comes from any other IDE but not in Xcode.

Upvotes: 3

ThomasW
ThomasW

Reputation: 17317

If what you want to do is know the value of the expression while program execution is halted, then do something like

> p (int)[somevariable count] 

in the gdb console.

Note: People searching for the term "watch" might be expecting an answer about being able to observe when a value changes. For that question these are some answers that are more appropriate:

Watching variables in Xcode

Xcode LLDB watchpoints

Upvotes: 10

Related Questions