Variable returns me nil finishing a function

0

At the time of wanting to add data to an array, the function shows me that the elements are added, but at the time that the tableView deploys what the array contains, it displays that it contains nothing, what can be the fails?

func descargarImagenes (secciones:String) {

        print(secciones, "En descargar Imagenes")
        //datosSeccion.seccion = secciones
        print("El valor de la clase datosSeccion de seccion es: \(datosSeccion.seccion)")

        let referenceImage = Storage.storage().reference().child("\(restauranteSeleccionado!)/secciones/\(secciones)/\(secciones).jpg")

        referenceImage.getData(maxSize: 1 * 2000 * 2000) { (data, error) in

            if let error = error {
                // Uh-oh, an error occurred!
                print("ERROR AQUI: \(error.localizedDescription)")
            } else {

                let imagen = UIImage(data: data!)

                let seccion = cellDatos(textoSeccion: secciones, imagenSeccion: imagen!)
                //self.datosSeccion.arrayCellData.append(seccion)
                self.datosSeccion.arrayCellData.append(seccion)

                print("Se puso la imagen wiiiii")
                print(seccion.textoSeccion)
                print(seccion.imagenSeccion)
                print(self.datosSeccion.arrayCellData.count)

            }

        }


    }

extension SeccionesVC: UITableViewDelegate, UITableViewDataSource{

    //MARK: - Funciones para TableView

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


    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let seccionChingona = datosSeccion.arrayCellData[indexPath.row]

        let cell = tableViewSecciones.dequeueReusableCell(withIdentifier: "cellSeccion") as! SeccionTVCell

        cell.setSeccion(seccion: seccionChingona)

        return cell

    }


    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 325
    }

    //-------------------------------------------------------------------------------------------


}
    
asked by Santiago Carrasco 04.02.2018 в 03:29
source

1 answer

0

You still need to notify the Tableview that you have new information:

add a reloadData() after setting the new images you have downloaded:

...
self.datosSeccion.arrayCellData.append(seccion)
self.tableViewSecciones.reloadData()
    
answered by 06.02.2018 / 16:25
source