If an exc_bad_access error occurs, it is basically caused by a memory leak and an error is released. The release operation is performed on a released object. However, xcode sometimes does not tell you where the error is (Visual Studio is doing well ). However, you can set the xcode environment variable nszombieenabled and mallocstacklogging to view the error source:
To set the xcode environment variable nszombieenabled and mallocstacklogging, take xcode4.5 as an example:
1. Click the product menu of xcode and select the edit scheme... option.
2. Select Run... on the left and click arguments on the right.
3. In the environment variables column, add nszombieenabled and set value to yes. Then add mallocstacklogging and set value to yes;
As shown in:
The above options are only valid on the simulator. If you change the IOS version, you need to reset it.
After debugging, remember to remove the environment variable nszombieenabled and mallocstacklogging because they will prevent memory from being released.
Memory leakage and excessive release Detection