zoukankan      html  css  js  c++  java
  • data parameter is nil 异常处理

    似乎是NSData的问题,用排除法分析了一下

         NSString *urlStr = [NSString stringWithFormat:@"%@/config/AppConfig.json",*******];
        [NetRequestHelp createNetRequestWithURL:urlStr parameters:nil requestType:CYRequestMethodTypeGET responseSeializerType:CYResponseSeializerTypeData completionHandle:^(BOOL success, id responseObject, NSString *message) {
            if(success)
                {
                NSDictionary *configDic = [JSONHelp JSONObjectWithData:responseObject];//当此处的responseObject为空的时候,就会报上面错误
                [configDic writeToFile:APP_CONFIG atomically:YES]; 
                
                } else { 
                
                } 
        }];
    

     此时在if(success){ }里面再加一层判断即可避免报上述错误

    
    
            if(responseObject == null) { 
    
                NSDictionary *configDic = [JSONHelp JSONObjectWithData:responseObject];//当此处的responseObject为空的时候,就会报上面错误
                [configDic writeToFile:APP_CONFIG atomically:YES]; 
                
                } else { 
                
                } 
    
    
    
  • 相关阅读:
    Docker之概述
    redis命令
    spring mvc(1) 为什么要使用mvc
    学习到的
    HttpWebRequest简单使用
    推手总结
    react 生命周期
    利用反射对应数据库字段
    扩展方法
    发送请求并返回
  • 原文地址:https://www.cnblogs.com/OIMM/p/10608518.html
Copyright © 2011-2022 走看看