How to debug EXC_BAD_ACCESS on the device only

advertisements

I have some code that returns a struct containing 2 objects (declared as id). When trying to use one of the objects I get an EXC_BAD_ACCESS and the app crashes. This only happens on the device (ipad) not in the simulator.

I have set NSZombieEnabled to YES, however no information is written to the console. I don't know if it's a problem that I'm using a workspace in Xcode 4, one project for my app, and another that builds a library which is used in my app. The EXC_BAD_ACCESS is occurring in the second project, so I don't know if NSZombieEnabled will apply to the second project?

How do I solve this? Especially as I it only happens on the device (even goes as planned on the simulator), and it is in the second project?

EDIT: This is the method where the EXC_BAD_ACCESS occurs, on line 62, on sortRange.lower –


It seems that one of your objects is autoreleased before you are trying to access it. As the iPad has less memory than the computer you are running it on it get's released faster so that's why it's not available. Try NSLog both objects just before the line you are getting the error and see wich one of them is the problem and than trace back to it's origin and retain it somehow. Also don't forget to release it after you are done using it. Some example code would be useful.