Bug Hunt: Instruments and the Debugger

Every programmer dreads the crash...EXC_BAD_ACCESS. When this error occurs, you know that something has tried to access an object that is no longer allocated. These are the hardest problems to find because the code causing the problem usually happens at a very different place from the exception. And although ARC cuts down on these errors, it does not prevent them.

Tracking down this kind of problem is best done with both Instruments and the debugger. Instruments helps you find what object is causing the problem, and then you can use breakpoints to test your hypotheses about how the dead object is being accessed.

To get some practice tracking down this kind of problem, open the project in CH14 CarValet Bug ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.