Watchpoints are used to monitor the value of a variable for changes; and to trigger a pause in the debugger when these changes happen. Hence, they can be very helpful in identifying state related problems in your program – that you might not know precisely how to track down.
Do it yourself
- Put a breakpoint in one of the methods; where you can print the value of the variable.
- Navigate to Variables View
- Expose the variable name (eg. by expanding self if it is an ivar)
- Right click on the variable name and select - Watch <name_of_your_var>
- Alternatively, you can also type in the LLDB console to set the watchpoint
watch set variable your_var_name
- A watchpoint watches for changes to the variable you specify. This means that when the variable’s value is set, the watchpoint will hit.
- Change variables type to "All".
- Check "value" for new value of your variable.
NOTE: Watchpoints are not saved between executions of your program.