1
In my App I need to list information registered by the user, there is an "enable" field where "on" will not be displayed in the tableViewController, if "yes" will list, code below for help. First item should not be displayed. Thank you.
let snapshot = self.listaDadosCombustivel[indexPath.row]
let key = snapshot.key
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "celulaDados", for: indexPath) as! CadastroDadosCell
let snapshot = self.listaDadosCombustivel[indexPath.row]
let key = snapshot.key
let snapshotAnterior = self.listaDadosCombustivel[indexPath.row.littleEndian]
self.idCadCombustivelAnterior = snapshotAnterior.key
if var dados = snapshot.value as? [String : Any]{
if let enable = dados["enable"] as? String{
if enable == "yes"{
if let dataAbastecimento = dados["dataAbastecimento"] as? String{
if let valorTotal = dados["valorTotal"] as? String{
if let litrosTotal = dados["litroTotal"] as? String{
if let kmAtual = dados["kmAtual"] as? String{
if let combustivel = dados["combustivel"] as? String{
if let consumo = dados["consumo"] as? String{
cell.dataLabel.text = dataAbastecimento
cell.valorTotalLabel.text = valorTotal
cell.litrosTotalLabel.text = litrosTotal
cell.combustivelLabel.text = combustivel
cell.kmVeiculoLabel.text = kmAtual
cell.kmLitroLabel.text = consumo
}
}
}
}
}
}
}else{
print(key)
}
}
}
return cell
}
it would be interesting you research on Codable, to make a Parser of this structure (listDadosCombustivel).
– Brenno Hayden