你好,你能幫我嗎我想在一個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