2019-01-07iOS|2019-01-07iOS 判断数组、字符串、字典是否为(nil/空指针/空)

//判断数组 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{ //不为空 }

    推荐阅读