@try { } @catch (NSException *exception) { } @finally { }
@try { // 可能会出现崩溃的代码 // meg = [MemberMeg parseFromData:data]; } @catch (NSException *exception) { // 捕获到的异常exception NSLog(@"main: Caught %@: %@", [exception name], [exception reason]); dispatch_async(dispatch_get_main_queue(), ^{ DXAlertView *alert = [[DXAlertView alloc]initWithTitle:@"提示" contentText:[NSString stringWithFormat:@"未知错误,稍后再试"] leftButtonTitle:nil rightButtonTitle:@"确定"]; [alert show]; }); } @finally { // 结果处理 }
iOS 异常处理机制
最新推荐文章于 2020-11-16 16:09:24 发布