-(void)applicationWillTerminate:(UIApplication*)application {
...
}
void HandleExceptions(NSException*exception){
DebugLog(@"This is where we save the application data during a exception");
// Save application data on crash
}
void SignalHandler(int sig) {
DebugLog(@"This is where we save the application data during a signal");
// Save application data on crash// Write your code to reset brightness
}
How to detect when an iOS app crashes
Great post on StackOverflow about detecting when an app is killed, due to an exception, a signal, etc.
Most crashes can be caught using a 3-fold approach:
- appWillTerminate
- exception handler
- signal handler
This translates into using:
// installs HandleExceptions as the Uncaught Exception Handler
NSSetUncaughtExceptionHandler(&HandleExceptions);
// create the signal action structurestruct sigaction newSignalAction;
// initialize the signal action structure
memset(&newSignalAction,0,sizeof(newSignalAction));
// set SignalHandler as the handler in the signal action structure
newSignalAction.sa_handler =&SignalHandler;
// set SignalHandler as the handlers for SIGABRT, SIGILL and SIGBUS
sigaction(SIGABRT,&newSignalAction, NULL);
sigaction(SIGILL,&newSignalAction, NULL);
sigaction(SIGBUS,&newSignalAction, NULL);
and:
My own answer to the same question, did not go as far as suggesting to intercept signals, but that is fundamental.
As I said, really great tip!
Advanced Breakpoints in Xcode
Xcode supports the possibility of setting symbolic breakpoints to inspect the status of your app when some odd condition occurs.
Year-end encryption export declaration
1. Visit the report generator
2. Fill the data (specify N/A when not sure because it likely does no apply)
3. Choose 5D992 for Export Control Classification Number
4. Select MMKT for Authorization Type
Xcode Layout Constraints Debugging
When you get the dreadful “will attempt to recover by breaking constraint” warning in Xcode, just know you can use the constraint address to filter the view hierarchy in “View Debugging/Capture View Hierarchy” and identify the broken constraint.