Information Technology Reference
In-Depth Information
Play a sound
You can combine actions without limit, adding and deleting them with the +/- buttons. You can also run mul-
tiple scripts simultaneously or run a script at the same time as you run a shell command.
For example, select the AppleScript option from the Action menu and type the following:
display dialog “Breakpoint %B, Count: %H”
Check the Automatically continue after evaluating actions box. Select Done and then build and run the applica-
tion.
NOTE
The %B option lists the breakpoint location, which is typically the method name and a line number. The %H option
lists the number of times the breakpoint has been triggered.
You won't see the alert shown in Figure 15.19, because your application has focus. This is a drawback of the ac-
tion system; some features don't work unless you can force focus or the action doesn't need it.
For this simple example, force focus manually by clicking anywhere in the Xcode window to bring the alert to
the front. Click OK or Cancel, and watch the count increment. With a more sophisticated script, you could
force focus from the script code and create a delayed loop that displayed the alert for a short period before con-
tinuing execution.
Actions are almost infinitely customizable. They're limited only by your imagination and scripting skills. A key
point is that you don't have to use them for manual debugging. You can use actions to create complex automatic
testing tools that can respond to external events, log code paths, and list variable values to log files. You can run
tests remotely, posting the results by e-mail or uploading them to a web server. These advanced options are spe-
cialized, and describing them in detail is outside the scope of this topic. But it's important to understand that
after you include actions, your debugging options become much more open-ended and creative.
FIGURE 15.19
Using simple scripting to create a custom breakpoint alert
Search WWH ::




Custom Search