How to debug EXC_BAD_ACCESS with NSZombie in XCode 5

When you happen to find yourself in the situation, when your app crashes, and XCode doesn’t give you enough info to solve the problem, its time to call for the NSZombie.

Thanks to NSZombies you will be able to see when an object that had already been deallocated receives a message, causing the app to crash. What’s more your console will fill with additional information, that may prove themselves useful.

To use NSZombies in XCode 5, you have to enable them. Do this by opening:

Product -> Scheme ->Edit Scheme…

Or by pressing – “Command <“

Then go to Diagnostics and check Enable Zombie Objects.

Now you can press: “Command I” to run Instruments and choose tracing for Zombies.

The last step is repeating the process that leads to calling EXC_BAD_ACCESS in your application. When the previously mentioned exception is called, you will see that instruments inform you about the Zombie object. Use the link that you will find in the information window, to go to the point which makes your app throw EXC_BAD_ACCESS. This is the moment when you are on your own. Go through your code considering the information that you will see in your console, and you will eventually find the way to solve EXC_BAD_ACCESS.

When you are done debugging, REMEMBER TO DISABLE Zombie Objects because it leaks every object, causing your application to render high memory usage.