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 { 
                
                } 
    
    
    
  • 相关阅读:
    Webpack安装及基础配置
    相机拍到了光源的灯珠图像
    面向对象特殊用法
    面向对象初始
    内置函数和必须的模块
    模块基本模式
    函数三
    函数二
    装饰器
    函数初识
  • 原文地址:https://www.cnblogs.com/OIMM/p/10608518.html
Copyright © 2011-2022 走看看