Ans. :
There are multiple aspects to your questions, let me try to answer them:
There are multiple aspects to your questions, let me try to answer them:
- NSSetUncaughtExceptionHandler only catches uncaught exceptions which is only a small subset of possible crashes.
- Exceptions in Objective-C are defined to be fatal and it is not recommended to catch them and even more not recommended to run any non-async safe code, which includes any Objective-C and Swift code.
- To catch crashes you need to setup signal handlers and then only run async-safe code at the time of the crash, which is only a small subset of C. Especially you may not allocate new memory at crash time at all.
NSSetUncaughtExceptionHandler(&HandleException);
signal(SIGABRT, SignalHandler);
signal(SIGILL, SignalHandler);
signal(SIGSEGV, SignalHandler);
signal(SIGFPE, SignalHandler);
signal(SIGBUS, SignalHandler);
signal(SIGPIPE, SignalHandler);
This will works for most situations.
No comments:
Post a Comment
Thanks