iOS闪退后调用的一些回调函数

- (void)catchCrash{
    NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
    //由挂起导致的终止信号
    signal(SIGHUP, ExceptionSignalHandler);
    //由中断导致的终止信号
    signal(SIGINT, ExceptionSignalHandler);
    //由退出导致的终止信号
    signal(SIGQUIT, ExceptionSignalHandler);
    //注册程序由于abort()函数调用发生的程序终止信号
    signal(SIGABRT, ExceptionSignalHandler);
    //注册程序由于非法指令产生的程序终止信号
    signal(SIGILL, ExceptionSignalHandler);
    //注册程序由于无效内存的引用导致的程序终止信号
    signal(SIGSEGV, ExceptionSignalHandler);
    //注册程序由于浮点数异常导致的程序终止信号
    signal(SIGFPE, ExceptionSignalHandler);
    //注册程序由于内存地址未对齐导致的程序终止信号
    signal(SIGBUS, ExceptionSignalHandler);
    //程序通过端口发送消息失败导致的程序终止信号
    signal(SIGPIPE, ExceptionSignalHandler);
}
/**
 捕获普通的闪退
 */
void UncaughtExceptionHandler(NSException *exception) {
   
}
/**
 捕获因内存访问错误,重复释放等原因的闪退
 */
void ExceptionSignalHandler(int signalval){
    UncaughtExceptionHandler(nil);
}
// 杀死程序时的回调
- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    UncaughtExceptionHandler(nil);
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。