Using the Xcode Debugger

You can use the debugger to do the following:

bullet_2c.tif Pause your app at any line of code.

bullet_2c.tif Pause your app if a condition is true.

bullet_2c.tif Step through code line by line.

bullet_2c.tif Skip over methods and functions.

bullet_2c.tif While the app is paused, view variables, objects, and memory.

The debugger is built into Xcode. You don’t need to modify your code to use it. But you do need to set one or more breakpoints, or pause locations.

genius_2c.eps

Breakpoints have many powerful options. You can set them to play a sound, run an external script, or generate a log message—among other options. Most of these options are specialized, and you don’t need them for basic debugging. But it’s useful to know that they’re available.

Breakpoints can be unconditional or conditional. Xcode always pauses at an unconditional breakpoint, but pauses at a conditional breakpoint only if a condition you specify is true. For example, ...

Get iOS App Development Portable Genius now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.