@try {
// 可能会出现崩溃的代码
//NSArray *data = [ListModel objectArrayWithKeyValuesArray:json[@"dataList"]];
} @catch (NSException *exception) {
// 捕获到的异常exception
NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"操作提示" message:@"系统出现问题,请稍后重试" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击确定");
}]];
[self presentViewController:alert animated:YES completion:nil];
});
} @finally {
// 结果处理
//回收资源
}
网友评论