通过RunLoop避免一次闪退

2020-06-30  本文已影响0人  萧城x

import <UIKit/UIKit.h>

import "AppDelegate.h"

void CrashHandlerExceptionHandler(NSException *exception) {

NSLog(@"%@",[exception callStackSymbols]);

CFRunLoopRef runLoop = CFRunLoopGetCurrent();

NSArray *allModes = CFBridgingRelease(CFRunLoopCopyAllModes(runLoop));

while (1)

{

    for (NSString *mode in allModes) {

        CFRunLoopRunInMode((CFStringRef)mode, 0.0001, false);

    }

}

}

int main(int argc, char * argv[]) {

@autoreleasepool {

    NSSetUncaughtExceptionHandler (&CrashHandlerExceptionHandler);

    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

}
上一篇 下一篇

猜你喜欢

热点阅读