Wednesday, October 13, 2010

Debugging BAD_ACCESS

If BAD_ACCESS bothers you and you have no idea where it come from, try enabling NSZombies


Enabling NSZombies

The solution to overreleased objects are the zombies. When this feature is enabled, a dummy object (a zombie) is kept on the place of every released object, thus allowing to debug objects which were released already. Very easy to enable:

Double click your executable in the “Executables” in XCode
Open “Arguments” tab
In “Variables to be set in the environment” (that’s the list at the bottom, be careful which one you edit) click the “+” button and for name of the variable enter “NSZombieEnabled” and for value “YES”
Voila!

Now instead of wondering what’s going on and which exact object produced the problem, you’ll see exactly which class is the trouble maker, and you’ll debug it quite fast.


http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/

No comments:

Post a Comment