NSZombieEnabled does not work

前端 未结 8 1666
谎友^
谎友^ 2020-12-15 07:59

When I set NSZombieEnabled = Yes nothing is written to the console. How can I fix this? Or can you advise me any other tools for an EXC_BAD_ACCESS?

相关标签:
8条回答
  • 2020-12-15 08:20

    I had a different experience with EXC_BAD_ACCESS, so I would like to share.

    As stated in the questions, even though NSZombieEnabled was checked, nothing was written to the console. After several hours of struggling in the simulator, I decided to install it to the device. The error message that I got from debugging with the device was more helpful.

    Eventually, I noticed that I was getting EXC_BAD_ACCESS error and strange behavior because I renamed a couple of xib files a day before. I selected the 'View Controller' object for MainWindow.xib file and corrected the NIB Name property. Then, everything worked smoothly.

    0 讨论(0)
  • 2020-12-15 08:21

    "EXC_BAD_ACCESS" is not necessarily related to a zombie instance. It can be linked an access to an undefined reference, like a local variable.

    NSArray *array;
    [array objectAtIndex:0]; // <- Will throw an error
    

    Edit: NSZombie flag will only help you to solve the "EXC_BAD_ACCESS" triggered by the use of a de-allocated instance.

    In order to solve the bugs, you have to use the crash backtrace to pinpoint the location that is wrong. Then, go backward into your code and check every assignment and allocations.

    0 讨论(0)
提交回复
热议问题