Kirsten Koa Kirsten Koa - 1 year ago 101
Objective-C Question

Is there a way to catch or handle EXC_BAD_ACCESS?

As far as I understand, EXC_BAD_ACCESS happens when you try to access bad memory (feel free to correct me if I'm wrong)?

Is there a way to kind of catch it like in a

to prevent total app failure?

Answer Source

Nope; EXC_BAD_ACCESS means things have gone wildly off the rails. Your program is trying to access a memory address that is invalid. I.e. memory has been corrupted and there is no predictable recovery.

It may be a memory management issue. If you can reproduce the issue, turn on NSZombies and see what happens. Or post the backtrace here.

Note that try-catch style exceptions are non-recoverable in iOS/Cocoa, too. Exceptions are not to be used for recoverable error handling. That is what NSError is for.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download