• 在ios开发中使用 try 和 catch 来捕获错误。


    本文转载至 http://blog.csdn.net/remote_roamer/article/details/7105776

      1. 抛出错误的代码
        1. //如果返回的报文是错误信息,则抛出错误  
        2.    if([outParams count] <= 0)  
        3.    {  
        4.        [NSException raise:@"WebService error" format:@"%@", returnJson4SOAP];  
        5.    }  
      2. 在调用中捕获错误代码
        1. //从soap 信息中解析出CusotmerDetail 对象  
        2.     @try  
        3.     {  
        4.         customerDetail = [[[SoapRtnJsonParser alloc] init] parse2CustomerDtail:[returnSoapXML dataUsingEncoding:NSUTF8StringEncoding]];  
        5.     }@catch (NSException * e) {  
        6.         NSLog(@"Exception: %@", e);  
        7.         UIAlertView * alert =  
        8.         [[UIAlertView alloc]  
        9.          initWithTitle:@"错误"  
        10.          message: [[NSString alloc] initWithFormat:@"%@",e]  
        11.          delegate:self  
        12.          cancelButtonTitle:nil  
        13.          otherButtonTitles:@"OK", nil];   
        14.         [alert show];  
        15.         [alert release];  
        16.         return;  
        17.     }  
  • 相关阅读:
    django自带登录认证与登录自动跳转
    11月份草稿2
    使用JavaScript实现字符串格式化
    requests与BeautifulSoup
    python+minicap(二)
    python+minicap的使用
    python+opencv图像处理(一)
    haproxy实现mysql从库负载均衡
    mysql 5.7 64位 解压版安装
    Redis基础教程
  • 原文地址:https://www.cnblogs.com/Camier-myNiuer/p/3825812.html
Copyright © 2020-2023  润新知