To monitor changes to the value of
variables or data items,you can set
watchpoints. A watchpoint pauses
execution of the program whenever the
value of the watched item changes. You
can set a watchpoint on a variable
only when execution of the program is
halted. To set a watchpoint on a
variable:
With execution of the program paused
at a breakpoint,select the variable
in the Variable list in the Debugger
window. See “Debugging in the
Debugger” to learn more about the
Variable list. Choose one of the
following: Run > Variables View >
Watch Variable Watch Variable from the
variable list shortcut menu Xcode
displays a magnifying glass next to
the variable to indicate that the
variable is being watched,as shown in
Figure 7-5. Figure 7-5 Watched
variable in the Variable list
When the value of the variable
changes,Xcode pauses execution of the
program and displays a dialog showing
the location of the program counter
and the new value of the variable. If
execution of the program moves beyond
the scope of the current variable,
Xcode deletes the watchpoint and
pauses execution of the program.
Important: Watching local variables,located on the stack,can cause your program to crash if system calls are made in the current function.