在IOS编程中,需要常用到tableview来显示从数据库查询的信息,同时也需要对与抛出的异常进行处理。
下面将在项目中遇到的异常信息处理进行解析:
具体代码如下:
@try {
records=[XTget getResource:strURL];
}
@catch (XXTException *exception) {
if (exception.exceptionType != -100 && exception.exceptionType !=-300) {
UIAlertView *alertview=[[UIAlertView alloc] initWithTitle:@"提示" message:@"抱歉,没有查询到您需要的信息"
delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
[alertview show];
records = nil;
}
return;//此处的return如果缺失,则会造成异常闪退,编程之中应该注意。
}
@finally {
}

本文介绍在iOS编程中使用TableView展示数据库信息时如何处理异常。通过一个具体的代码示例,展示了如何使用@try、@catch和@finally语句块来捕获并处理异常,确保应用程序的稳定运行。
1171

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



