先贴一下我在OC的代码
void UncaughtExceptionHandler(NSException * exception)
{
      //崩溃的回调
}
+ (void)setDefaultHandler
{
    NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
    signal(SIGABRT, SignalHandler);
    signal(SIGILL, SignalHandler);
    signal(SIGSEGV, SignalHandler);
    signal(SIGFPE, SignalHandler);
    signal(SIGBUS, SignalHandler);
    signal(SIGPIPE, SignalHandler);
}
void SignalHandler(int signal)
{
}
OC的情况可以回调
在Swift由于没有了指针,所以不能像OC一样写了,下面是Swift在Appdelegate的代码
NSSetUncaughtExceptionHandler({ (expcetion) in
     //崩溃回调
 })关于这个不回调的,我查了一些帖子参考
https://stackoverflow.com/questions/25441302/how-should-i-use-nssetuncaughtexceptionhandler-in-swift
https://www.ibm.com/developerworks/cn/cloud/library/cl-mqa-swift-app/index.html
参考了这些帖子,这个NSSetUncaughtExceptionHandler放在一个OC的类中调用,然后在OC调用这个类,但是发现没效果。有朋友做过Swift版的全局异常捕获吗?请赐教一下,谢谢了