Reputation: 12509
I've found that my iOS 5 app is sometimes unexpectedly quited and it does not seem to be due to an uncaught exception, since I've implemented uncaughtExceptionHandler
in the app delegate class and I get nothing from there.
If it is because the system is terminating it, it looks like you can only be aware of that if it is in background state: I've read the following line in Apple's documentation.
The
applicationWillTerminate:
method is not called if your app is currently suspended.
So, if I'm not wrong, you can get the reason why your app is terminated by the system in these cases:
Can I detect more causes of why the app is being terminated, in order to report the issue? Or is it possible that it is not currently being terminated, but moved to background without user interaction?
Thanks
Upvotes: 0
Views: 236
Reputation: 22946
NSSetUncaughtExceptionHandler()
installs a handler for Objective-C exceptions (e.g. trying to access an NSArray
item that does not exist). It does not catch the lower level signals like segmentation fault, bus error, illegal instruction, ..., things that happen when your app for example tries to access an invalid pointer address.
You can also install handlers for those:
#include <signal.h>
void signalHandler(int signal)
{
}
// Somewhere in your start-up code.
signal(SIGSEGV, signalHandler);
Upvotes: 2