I'm trying to display a UIAlertView in a top-level iPhone exception handler. The handler function looks like this:
void applicationExceptionHandler(NSException *ex) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[ex reason]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
I've seen similar code elsewhere (for instance, http://stackoverflow.com/questions/1128539/).
If I single-step in the debugger, I can see that the exception handler is called, and I can see the current screen dim as if it's going to display the alert in front of it, but nothing appears. Outside of the debugger, the app just quits immediately and goes back to the system home screen.
It does work if I trap an error in applicationDidFinishLaunching and display an alert there before returning. I assume that the alert view never gets a chance to display in the exception handler because the app is terminating (as opposed to sitting there doing nothing if I just bail out of applicationDidFinishLaunching). Is there a way to make this work?