Aural Breakpoints

Software

Breakpoints are a time-tested debugging mechanism, but sometimes bringing your application to a halt will interrupt the very thing you’re debugging. This issue often comes up when creating UI elements that can be pinched, dragged, or rotated. Often, the best way to inspect these events is to hear audio feedback, allowing you to debug without pausing the app or taking your eyes off the screen. In this post, I’ll show how to use Xcode’s breakpoint features that utilize sound.

Set Up

In this example, I’m debugging the pinch gesture code from a previous post. We’ll start by clicking on the bar to the left of the text to create a breakpoint. From here, we can right-click and select ‘Edit Breakpoint…‘.

auralBps0

Now we should see a menu that looks like this:

auralBps1

On this menu we’ve checked off ‘Automatically continue after evaluating‘. This allows us to use the breakpoint to inject some behavior without pausing the execution of the app.

Pre-Canned Sound Bites

If we press the ‘Add Action‘ button, we’ll get a drop down menu. Select ‘Sound‘ to get a list of sound bites. This sound will play each time the breakpoint is triggered. This is ideal if we just want to know that our line of code is being run.

auralBps2

Detailed Feedback

Sometimes a simple confirmation that your code is running is not enough. We’re debugging this code because we need to examine it in more detail. If we switch the action to ‘Log Message‘ and select ‘Speak message‘, we will get text-to-speech feedback. We can even format the text that will be spoken.

auralBps3

Let’s explore some possible inputs, coupled with the output that they would produce:


pinch began

“pinch began”


%B

“handlePinch:” (the name of the function being evaluated)


@pinch@

“0x1894470” (the memory address of the UIPinchGestureRecognizer object)


@[pinch class]@

“UIPinchGestureRecognizer”


@[self percentForPinch:pinch]*100.0f@ percent

“zero percent” (because the gesture has just started)


Other Features

That’s it for audio-related features, but there are other interesting features in this breakpoints menu. I encourage you to continue to explore this nook of Xcode and learn about all the things you can do with breakpoints.

Advertisements

2 thoughts on “Aural Breakpoints

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s