iphone object_c 也支持异常捕获,用过没有呀。 在处理UITableView, MKMapView等,你可以加一些异常捕获,因为显示数据常常出错。
下面是示例代码:
@try { Statements } @catch (NSException *ex) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[ex name] message:[ex reason] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; }
注意,你的方法中要支持UIAlertViewDelegate协议。
本文介绍如何在Objective-C中使用异常捕获来处理UITableView和MKMapView等组件显示数据时可能遇到的问题。通过示例代码展示了如何利用@try和@catch来捕获并展示异常信息。

被折叠的 条评论
为什么被折叠?



