iOS_判断数组为空
2020-01-03 本文已影响0人
Qy_iOS
//判断数组
if(self.dataArray!=nil&&![self.dataArray isKindOfClass:[NSNull class]]&&self.dataArray.count!=0){
}
//判断字典
NSDictionary*dict=self.datas[indexPath.row];
if([[dict allKeys]containsObject:@"key"]){
cell.textLabel.text=[dict valueForKey:@"key"];
}else{cell.textLabel.text=@"没有对应的key值";
}
//判断字符串
if(string==nil||string==NULL||[string isKindOfClass:[NSNull class]]||[[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]length]==0)
{
//空
}else{
//不为空
}