Watch expression in Xcode

Say I'm debugging. Let's say I need to know that the value of [somevariable count]

How can I do it?

+4
source share
2 answers

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

> p (int)[somevariable count] 

in the gdb console.

Note: People who are looking for the term β€œwatch” may expect a response about being able to observe a change in value. For this question, these are some more suitable answers:

View variables in Xcode

Xcode LLDB Observation Points

+10
source

Place a breakpoint on the appropriate line of code. When Xcode stops at this line, in the debug area (the bottom of the screen is divided into two parts, look at the right, if you do not see the bottom, shift + cmd + Y, plus sometimes the right side or the left side is hidden, and on the right bottom side there are small buttons to show them), you see all local and global variables. Right-click (or two fingers) the debug area, and you will see a context menu with one of the "add expression" options. Enter your expression.

Note: Above the previous user comment about the word β€œwatch,” it’s pretty clear who comes from any other development environment, but not in Xcode.

+2
source

All Articles