こんにちは、私はTableViewにオブジェクトの配列を表示したいが、配列の構成要素は1つだけ表示したい。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
}
}
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