views:

84

answers:

1

I need to catch ALL exceptions and errors in an iphone app. Obviously, this is only for really strange cases where the exception or error is totally unexpected. In those cases, it would be nice to log the error or something, so as to get knowledge of the issue and fix it in the future.

Do you know a way to catching ALL exceptions or errors that might have slipped from more specific handlers?

Thanks!

A: 

In your app delegate put this function (note it's not a method, it's a standalone function):

// global uncaught exception handler
void uncaughtExceptionHandler(NSException *exception) {
    [FlurryAPI logError:@"Uncaught" message:@"Crash!" exception:exception];
}

And at the top of your applicationDidFinishLaunching*:

    // uncaught exceptions
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
ZaBlanc
That is only if you are using Flurry Analytics in your project.
iWasRobbed