There are some solutions to this problem on the Internet, but most of them are unclear. I will describe the specific steps based on my own practices.
1.
In the groups & files/executables folder of xcode, double-click, select arguments, select the following column, click "+", and add four variables named respectively: set nszombieenabled, mallocstacklogging, nsdebugenabled, mallocstackloggingnocompact, and value to yes.
2.
If exc_bad_access appears, the following information is displayed in the console prompt:
13:44:18. 300 aproject [4009: 207] ***-[cfstring class]: Message sent to deallocated instance 0x5e463b0
Enter shell malloc_history in the console4009 0x5e463b0. Here4009Is4009, Indicating the process number,0x5e463b0Is the above0x5e463b0Indicates the variable address of the error.
Press enter. The console will output some information, some of which begin with alloc or free. These are memory request or release records that contain messages sent to these objects. An error usually occurs in the last message starting with alloc or malloc. Find the last message written by yourself. The problem is this message. In this way, you can locate the line of code with an error.
Main reference: http://blog.sina.com.cn/s/blog_6cffce770100ub98.html
By zqzhuang