views:

90

answers:

1
A: 

A lot of times the line that you are on when you receive EXC_BAD_ACCESS isn't the line that is causing the problem. I put a full explanation of what EXC_BAD_ACCESS is and how to find it here:

http://www.loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html

The upshot is that usually you are talking to released objects or you have corrupted a pointer or the heap. Here are the easiest things to do:

  1. Run a Build and Analyze and specifically look at the issues where it says that you might be releasing too many times. It might also complain of leaks (which you should fix), but those can't cause EXC_BAD_ACCESS

  2. Run the application with NSZombiesEnabled (see link). This causes all objects to never deallocate, but instead turn into zombies when their retainCount gets to 0. If you try to send a message to a zombie, it will complain in the console on the exact line that is causing the problem.

  3. If neither of those work, then you need to look for pointer/heap corruption. The best way to do that is to Enable Guard Malloc (see link) and use the gdb commands to inspect the heap.

Lou Franco