【发布时间】:2017-06-19 20:41:30
【问题描述】:
你好,你能帮我吗?我想在 TableView 中显示一个对象数组,但只有一个数组的组成部分。
这里是我的代码:
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
}
}
所以..我想在这一行显示,只有 DestinoInstancia.desDestino = dep.desDestino!
cell.textLabel?.text = String(describing: autoCompleteDestino[index])
目前以这种方式显示:
MTiOS.Destinos(idDestino: Optional(1), desDestino: Optional("Asunción")), MTiOS.Destinos(idDestino: Optional(2), desDestino: Optional("Miami")), MTiOS.Destinos(idDestino : Optional(3), desDestino: Optional("Atenas")), MTiOS.Destinos(idDestino: Optional(5), desDestino: Optional("Madrid"))]
当我只想给我看时:
亚松森 迈阿密 阿泰纳斯 马德里
请帮忙!
【问题讨论】:
-
看起来你没有解开这些选项。
-
我想..是的,我打开包装:DestinoInstancia.idDestino = dep.idDestino! DestinoInstancia.desDestino = dep.desDestino!
标签: arrays swift uitableview tableviewcell