在ios开发中使用 try 和 catch 来捕获错误。
2011-12-27 14:34
369 查看
抛出错误的代码
在调用中捕获错误代码
//如果返回的报文是错误信息,则抛出错误 if([outParams count] <= 0) { [NSException raise:@"WebService error" format:@"%@", returnJson4SOAP]; }
在调用中捕获错误代码
//从soap 信息中解析出CusotmerDetail 对象 @try { customerDetail = [[[SoapRtnJsonParser alloc] init] parse2CustomerDtail:[returnSoapXML dataUsingEncoding:NSUTF8StringEncoding]]; }@catch (NSException * e) { NSLog(@"Exception: %@", e); UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"错误" message: [[NSString alloc] initWithFormat:@"%@",e] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [alert show]; [alert release]; return; }
相关文章推荐
- IOS开发之--异常处理--使用try 和 catch 来捕获错误。
- 在ios开发中使用 try 和 catch 来捕获错误。
- 在ios开发中使用 try 和 catch 来捕获错误。
- 在ios开发中使用 try 和 catch 来捕获错误。
- 在ios开发中使用 try 和 catch 来捕获错误。
- iOS中@try@catch@finally捕获异常使用
- iOS中@try@catch@finally捕获异常使用
- 后台判断格式是否想要的类型可使用 try{} catch{}捕获错误,
- iOS中try-catch-finally捕获异常使用
- sql语句trycatch捕获错误信息
- iOS - try~catch捕获异常防止崩溃简单实用
- 使用lua实现try-catch异常捕获
- iOS开发过程中使用Core Data应避免的十个错误
- js错误处理try..catch使用
- Foreach语句,Throw语句,Try,catch语句的使用,报告编译错误
- 【工控机开发】linux下错误的捕获:errno和strerror的使用
- Android开发如何使用UncaughtExceptionHandler捕获程序崩溃错误信息?
- 使用try/catch捕获异常
- iOS开发——常见错误——使用MJRefresh返回上一个界面蹦掉的情况
- ios定位开发 当使用百度地图sdk没有启用object c++混编时就会出现如下错误