class ViewController: UIViewController,UITableViewDelegate, UITableViewDataSource { var staedte = [Stadt]() let staedteDB:StaedteDB = StaedteDB() func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return staedte.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "cell") if cell == nil { cell = UITableViewCell(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: "cell") } let row = (indexPath as NSIndexPath).row let stadt:Stadt = staedte[ row ] cell?.textLabel!.text = stadt.name cell?.detailTextLabel!.text=stadt.bemerkung switch (stadt.kontinent) { case Continent.AFRIKA: cell?.imageView!.image = UIImage(named: "schwarz") case Continent.AMERIKA: cell?.imageView!.image = UIImage(named: "rot") case Continent.ASIEN: cell?.imageView!.image = UIImage(named: "gelb") case Continent.AUSTRALIA: cell?.imageView!.image = UIImage(named: "gruen") case Continent.EUROPA: cell?.imageView!.image = UIImage(named: "blau") default: cell?.imageView!.image = UIImage(named: "schwarz") } return cell! } // SelectecIndexChanged func tableView(_: UITableView, didSelectRowAt: IndexPath) { bnChange.isEnabled=true let row = (didSelectRowAt as NSIndexPath).row labelStadt.text="row: "+String(row) }