你好,你能帮我吗我想在一个TableView中显示一个对象数组,但只有一个数组的组成部分。如何在TableView中显示对象数组swift
这里我的代码:
extension ViewController: UITableViewDataSource {
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
let index = indexPath.row as Int
for dep in autoCompleteDestino {
DestinoInstancia.idDestino = dep.idDestino!
DestinoInstancia.desDestino = dep.desDestino!
autoCompleteDestino.append(dep)
}
print(autoCompleteDestino)
cell.textLabel?.text = String(describing: autoCompleteDestino[index])
return cell
}
}
So..i想在这一行中,只有DestinoInstancia.desDestino = dep.desDestino展现!
cell.textLabel?.text = String(describing: autoCompleteDestino[index])
目前显示我这样说:
MTiOS.Destinos(idDestino:可选(1),desDestino:可选( “亚松森”)),MTiOS.Destinos(idDestino:选购(2) ,可选(“迈阿密”)),MTiOS.Destinos(idDestino:可选(3),desDestino:可选(“Atenas”)),MTiOS.Destinos(idDestino:可选(5),desDestino:可选(“Madrid” ))]
当我只想告诉我:
亚松森 迈阿密 阿特纳斯 马德里
请帮助!
看起来你不打开这些可选项。 – ffritz
我认为..,我解开:DestinoInstancia.idDestino = dep.idDestino! DestinoInstancia.desDestino = dep.desDestino! – xhinoda