ios捕获异常

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];  
} 

原文地址:https://www.cnblogs.com/peer/p/2043886.html