解析JSON格式的数据时,有的字段为空值,这个时候不能像平常的与nil比较,而要

一种做法是

NSString *comDic = [[data objectAtIndex:0]  objectForKey:@"CompanyDicNoHtml"];
  NSInteger length = [[comDic dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES] length];
  if(length != 0){

}这种做法我有验证,是可行的

第二种是用[NSString stringWithFormat:@"%@",[[data objectAtIndex:0]  objectForKey:@"Location"]];

格式化后,再比NIL比较


 

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2021-06-29
  • 2022-12-23
  • 2021-08-18
  • 2021-11-17
  • 2021-07-22
  • 2021-11-15
相关资源
相似解决方案