iOS 异常处理机制

来源:互联网 发布:我的世界,java.net 编辑:程序博客网 时间:2024/05/20 16:12
    @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 { // 结果处理 }


原创粉丝点击