Information Technology Reference
In-Depth Information
For example, this line of code runs the standard Objective-C sel_getName function on the selected variable
and outputs the description as a summary string:
{(char *) sel_getName($VAR)}:s
Data formatters can create some very sophisticated effects. You have almost total freedom to select and combine
data from any object in your application and to display it as you choose. However, the programming cost can be
substantial. Custom data formatters are best reserved for more complex projects where Xcode's other features
can't display data in a useful way.
Tip
You can define your own custom data formatters and import them into Xcode. The process is moderately complex,
but you need to do it only once. You can then reuse the formatters in any project. For details, see the Viewing
Variables and Memory section of Xcode Debugging Guide in the documentation.
Adding watchpoints
A watchpoint is loosely related to a breakpoint, but it's triggered when a variable is modified. Use the Watch
Address of… option in the right-click contextual menu to create a watchpoint, as shown in Figure 15.16.
There's no way to add a watchpoint using the code editor.
When the watchpoint is triggered, Xcode logs a message to the console and highlights the line of code that
modified the variable in the code editor. Messages list the values of the variable before and after the watchpoint
was triggered.
CAUTION
There's no way to delete a watchpoint manually. A watchpoint is deleted automatically when execution moves
beyond the scope of the watched variable. This is strange behavior and not entirely helpful; for better or worse,
watchpoints are only loosely related to breakpoints. Internally, they modify the stack. This means system calls are
likely to crash if you set a watchpoint for a local stacked variable, because this operation modifies the stack.
Search WWH ::




Custom Search