https://github.com/lsmakethebest/LSSafeProtector
cocoapods 配置文件添加:
#防止值为空导致的crash
pod 'LSSafeProtector'
appdelegate.m文件配置:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
////开启防止奔溃
// IsDebug=YES代表开发环境 捕捉到崩溃 ,会打印崩溃信息,同时利用断言闪退,会回调block
// IsDebug=NO,代表线上环境,拦截到崩溃不打印崩溃信息,也不会断言闪退,会回调block
[LSSafeProtector openSafeProtectorWithIsDebug:NO block:^(NSException *exception, LSSafeProtectorCrashType crashType) {
//[Bugly reportException:exception];
DEBUGLOG(@"%@",exception);
}];
...
}
网友评论