//当 请求网络 或者获取其他返回数据 首先 要做一次判断 数据是否为空 

防止程序崩溃 

程序崩溃 好比拿刀扎在程序员的心啊~

  

if(为空)
{
     做提示对话框等操作
}
else
{
     正常执行
}
 - (BOOL) isBlankString:(NSString *)string {//判断字符串是否为空 方法

    if (string == nil || string == NULL) {
        return YES;
    }
    if ([string isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
        return YES;
    }
    return NO;
} 

 

相关文章:

  • 2022-02-10
  • 2021-12-04
  • 2022-12-23
  • 2021-12-04
  • 2022-02-21
  • 2022-02-04
  • 2021-05-31
  • 2022-02-09
猜你喜欢
  • 2022-02-23
  • 2022-12-23
  • 2022-01-01
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
相关资源
相似解决方案