Say I have a variable, self.position
, how do I get Xcode to break whenever it changes its value (a number of methods could change it).
To set a conditional breakpoint, activate the context menu in the source pane, on the line where you want the breakpoint, and select “Add Conditional Breakpoint”. You'll then see a textbox where you can enter the expression. Press Return to finish.
Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.
In fact, you can now right-click a variable name in the Local window and then select Break When Value Changes (see Figure 58). Visual Studio will automatically track your variable, and it will break the application execution when the variable value changes.
Add breakpoints to your projectAdd a breakpoint by clicking the gutter next to the line number you want to pause at. A dot will appear next to the line number, and the line will be highlighted.
For conditional breaking:
For breaking on every occasion the value has changed:
If you want to see who invoked the setter - just look at the next line in the stack trace (viewDidLoad in my example):
Update:
Adding a watchpoint
(lldb)
prompt shows up in the consolewatchpoint set variable _position
(replace _position with an iVar you want to watch)watchpoint modify -c "_position < 0.5" 1
where the expression in quotes is the condition and the number at the end is the watchpoint number you noted in #3.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With