2
class OcorrenciaVinculadaCell: UITableViewCell{
@IBOutlet weak var tipoOcorrencia: UITextField!
@IBOutlet weak var descricao: UITextField!
}
class OcorrenciaVinculadasViewController: UITableViewController {
var id:Int = 0;
var schedulingId = 0;
var ocorrencias:Array<Ocorrencia> = [];
override func viewDidLoad() {
self.schedulingId = Util.schedullingId;
OcorrenciaHttp.GetOcorrencia(
success: {
(ocorrencias) in
self.ocorrencias = ocorrencias;
self.tableView.reloadData();
}
,fail: { (error) in
print("Failure: \(error.localizedDescription)");
}
);
}
@IBAction func createOcorrenciaButton(_ sender: Any) {
Util.schedullingId = schedulingId;
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ocorrencias.count
}
override func tableView(_ tableView: UITableView, cellForRowAt
indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "itemCell", for: indexPath) as! OcorrenciaViewCell
let ocorrencia = ocorrencias[indexPath.row]
cell.tipoOcorrencia.text = Util.GetText(text:ocorrencia.tipoOcorrencia?.Name) as? String;
cell.descricao.text = Util.GetText(text: ocorrencia.descricao) as? String;
return cell
}
In return keeps giving the error:
Cannot convert return expression of type 'OcorrenciaViewCell' to return type 'UITableViewCell'
this is occurring because the function
tableView
waits for an object of the type to be returnedUITableViewCell
but you are returningcell
which is an object of the typeOcorrenciaViewCell
:let cell = tableView.dequeueReusableCell(withIdentifier: "itemCell", for: indexPath) as! OcorrenciaViewCell
. You’d have to convertcell
inUITableViewCell
only your question does not show the statement ofOcorrenciaViewCell
to know if it is possible or would have to create a conversion method.– Augusto Vasques