在ios开发中使用 try 和 catch 来捕获错误。
生活随笔
收集整理的這篇文章主要介紹了
在ios开发中使用 try 和 catch 来捕获错误。
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
轉(zhuǎn)載自:http://blog.csdn.net/remote_roamer/article/details/7105776
拋出錯(cuò)誤的代碼
[cpp]?view plaincopy //如果返回的報(bào)文是錯(cuò)誤信息,則拋出錯(cuò)誤?? ???if([outParams?count]?<=?0)?? ???{?? ???????[NSException?raise:@"WebService?error"?format:@"%@",?returnJson4SOAP];?? ???}?? 在調(diào)用中捕獲錯(cuò)誤代碼
[cpp]?view plaincopy //從soap?信息中解析出CusotmerDetail?對(duì)象?? ????@try?? ????{?? ????????customerDetail?=?[[[SoapRtnJsonParser?alloc]?init]?parse2CustomerDtail:[returnSoapXML?dataUsingEncoding:NSUTF8StringEncoding]];?? ????}@catch?(NSException?*?e)?{?? ????????NSLog(@"Exception:?%@",?e);?? ????????UIAlertView?*?alert?=?? ????????[[UIAlertView?alloc]?? ?????????initWithTitle:@"錯(cuò)誤"?? ?????????message:?[[NSString?alloc]?initWithFormat:@"%@",e]?? ?????????delegate:self?? ?????????cancelButtonTitle:nil?? ?????????otherButtonTitles:@"OK",?nil];??? ????????[alert?show];?? ????????[alert?release];?? ????????return;?? ????} ?
[cpp]?view plaincopy
[cpp]?view plaincopy
轉(zhuǎn)載于:https://www.cnblogs.com/viktyz/archive/2012/06/28/2872136.html
總結(jié)
以上是生活随笔為你收集整理的在ios开发中使用 try 和 catch 来捕获错误。的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SQLServer跟踪相关
- 下一篇: asp网页设计流量统计代码