Error recovering data from firebase with Xcode

Asked

Viewed 65 times

0

I am error to recover information from firebase, check the codes: From what I understood in the mistakes I am doing something wrong to recover the data, must be something with the data dictionary...

I am adding without error:

To add

@IBAction func RegistrarReparoBuraco(_ sender: UIButton) {
        ref = FIRDatabase.database().reference()
        //ref?.child("Reparos").childByAutoId().setValue(Coordenadas)

        ref?.child("Reparos").child((FIRAuth.auth()?.currentUser?.uid)!).childByAutoId().setValue(
            [
                "DIA_SOLICITACAO" : dataSolicitacao.text!,
                "OBSERVACOES" : observacoes.text ?? "",
                "COORDENADAS" : Coordenadas,
                "CELULAR": celular.text ?? "",
                "SITUACAO": "Aguardando",
            ]
        )

        Cleaner()
    }

Can anyone help? I don’t have much experience...

model class

import UIKit

class RegistroModel: NSObject{

    var diaSolicitacao: String?
    var situacao: String?
    var coordenadas: String?


}

class retrieving firebase information

import UIKit
import Firebase
import FirebaseDatabase

class ViewControllerRegistros: UITableViewController{


    @IBOutlet var tblRegistros: UITableView!


    var ref: FIRDatabaseReference!
    var refHandle: UInt!
    //let cellId = "cellId"
    var RegistroList = [RegistroModel]()

    override func viewDidLoad() {
        super.viewDidLoad()
        //FIRDatabase.database().persistenceEnabled = true
        ref = FIRDatabase.database().reference()
        fetchRegistros()

           }


    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return RegistroList.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cellId")

        //set cell contents
        cell.textLabel?.text = RegistroList[indexPath.row].situacao


        return cell

    }

    func fetchRegistros(){

        refHandle = ref.child("Reparos").observe(.childAdded, with: {(snapshot) in

            if let dictionary = snapshot.value as? [String: AnyObject]{

                let registro = RegistroModel()

                registro.setValuesForKeys(dictionary)
                self.RegistroList.append(registro)

                DispatchQueue.main.async{
                    self.tableView.reloadData()


                }
            }
        })

    }

Data structure of firebase

Reparos
 a6GeSfL1gMfeCccjEGSJxEflxPZ2
 -KjNXMOtwVXlRtkga4As
 CELULAR: "041 96972354"
 COORDENADAS: "Optional(\"(37.785716629014757, -122.40611205304..."
 DIA_SOLICITACAO:"May 5, 2017 at 9:14 AM"
 OBSERVACOES:"Aaafdsfsdfsdfsdfsfsfsdfsdfsd"
 SITUACAO: "Aguardando:


}
  • What is the language? Xcode is the IDE.

  • This... Xcode with Swift 3

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.