1. 在程序启动时加上一个异常捕获监听,用来处理程序崩溃时的回调动作 NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler); 官方文档介绍:Sets the top-level error-handling function where you can perform last-minute logging before the program terminates. UncaughtExceptionHandler是一个函数指针,该函数需要我们实现,可以取自己想要的名字。当程序发生异常崩溃时,该函数会得到调用,这跟C,C++中的回调函数的概念是一样的。