I have 2 tableviews with the datasource and delegates in a view controller and the console prints the results, but when the simulator beggin the tables are empty
class firs: UIViewController, UITableViewDataSource, UITableViewDelegate, MyCustomCellDelegator {
@IBOutlet weak var tablarecibido: UITableView!
@IBOutlet weak var tablaenviado: UITableView!
let appdelegate = UIApplication.shared.delegate as! AppDelegate
var resultsenviadas: [Notificacionesenviadas] = []
var resultsrecibidas: [Notificaciones_entity] = []
var statusr = ""
var emisorr = ""
var nombrer = ""
let cellIdentifier = "cellrecibido"
let cellenviado = "cellenviado"
override func viewDidLoad() {
super.viewDidLoad()
let savemyprofile = SaveMyProfile()
uid = savemyprofile.getUidSesion()
self.getNotificacionesRecibidas()
self.getNotificacionesEnviadas()
self.addNotificaciones()
self.tablarecibido.dataSource = self
self.tablarecibido.delegate = self
self.tablarecibido.register(cellpersonalizada.self, forCellReuseIdentifier: "cellrecibido")
self.tablaenviado.dataSource = self
self.tablaenviado.delegate = self
self.tablaenviado.register(enviadas.self, forCellReuseIdentifier: "cellenviado")
self.tablarecibido.reloadData()
self.tablaenviado.reloadData()
}
@available(iOS 2.0, *)
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var results: Int?
if (tableView == tablarecibido) {
results = self.resultsrecibidas.count
return results!
}
else if (tableView == tablaenviado) {
results = self.resultsenviadas.count
return results!
}
return results!
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (self.tablarecibido != nil) {
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath as IndexPath) as! cellpersonalizada
cell.uid = uid
cell.delegate = self
cell.status = self.resultsrecibidas[indexPath.row].status
cell.key = self.resultsrecibidas[indexPath.row].key
cell.emisor = self.resultsrecibidas[indexPath.row].emisor
cell.nombre = self.resultsrecibidas[indexPath.row].nombre
cell.keytext.setTitle(self.keyr,for: .normal)
cell.btnverperfiltext.setTitle(self.nombrer,for: .normal) // cell.label!.text = "hola"
///Users/usuario/Desktop/tasdf/tasdf/Vista.swift cell.btnverperfiltext.setTitle(self.resultsrecibidas[indexPath.row].nombre!, for: .normal)
return cell
}else{
let cell2 = tableView.dequeueReusableCell(withIdentifier: cellenviado, for: indexPath as IndexPath) as! enviadas
cell2.k?.text = "hola"
return cell2
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// cell selected code here
}
I try a lot of things but the simulator don´t do anything.(The other part of the code I hint but the console prints values)