本文转载至 http://blog.csdn.net/remote_roamer/article/details/7105776
- 抛出错误的代码
- if([outParams count] <= 0)
- {
- [NSException raise:@"WebService error" format:@"%@", returnJson4SOAP];
- }
- 在调用中捕获错误代码
- @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;
- }