How do you watch a variable in xcode 4? I'm not sure how to do this.
-
2possible duplicate of [Where is the expression window in Xcode 4?](http://stackoverflow.com/questions/5632477/where-is-the-expression-window-in-xcode-4) Just enter the variable name as expression. – osgx May 12 '11 at 17:57
-
thanks my question is a dupe. – lampShade May 12 '11 at 18:21
-
same question here http://stackoverflow.com/questions/6500718/does-xcode4-have-a-watch-window – Nabil Sham Nov 05 '12 at 00:33
3 Answers
Right click in the local variables window to see the "Watch Expression" menu command. Type the variable name and the variable will be added.

- 681
- 6
- 12
There is 2 ways to watch a variable and break at certain condition.
- Edit breakpoints
Control-click a breakpoint indicator to display a command menu and choose Edit Breakpoint to open the breakpoint editor and set conditions, add actions, and so forth, as mentioned in Breakpoints.
Use LLDB command line. For example, below command will watch the value of 'I', and break when I==3.
(lldb) watch set var i Watchpoint created: Watchpoint 1: addr = 0x100001018 size = 4 state = enabled type = w declare @ '/Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp:12' (lldb) watch modify -c 'i==3' (lldb) watch list
This is where you can type LLDB command in Xcode.

- 2,787
- 2
- 20
- 29