views:

240

answers:

3

Hi,

I was using an app the other day that crashed, but as it crashed also asked to send an email with the crash info.

Does anyone know how this is done?

Perhaps it was an exception handler in the code that before it lets the app die, sent the email, but just wondering if there are any onCrash type hooks in the iphone sdk.

Thanks, Chris

+3  A: 

You basically wrap your entire application in a try/catch and if you catch an error you can offer to phone home with the details.

Andrew Grant
+4  A: 

PLCrashReporter attempts to provide a framework to do exactly this. Not used it myself yet but considering it.

Stephen Darlington
Isn't this the kind of 3rd party framework that gets your app rejected by Apple?
Sam V
I don't see why it couldn't be implemented using only public, approved APIs. Having said that, I don't know the specifics. If you include it in your app it is a risk.
Stephen Darlington
A: 

There seems to be this hook available just before the app shuts down:

NSSetUncaughtExceptionHandler()

Sets the top-level error-handling function where you can perform last-minute logging before the program terminates.

Chris Kimpton