Я создал словарь (массив). Когда я нажимаю на tableViewCell, я попадаю в DetailViewController. DetailViewController состоит из titleLable, descriptionLable и ImageView. Когда я отфильтрую свои данные и нажму, например, «FILTERED ROW NR 2», я получу заголовок и изображение «FILTERED ROW NR 2», но descriptionLabeL из строки номер два в верхней части словаря.
Кто-нибудь может мне помочь? Что я делаю не так?
my code is:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if searching {
return searchCountry.count
} else {
return countrynameArr.count
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if searching {
cell.textLabel?.text = searchCountry[indexPath.item]
return cell
} else {
cell.textLabel?.text = countrynameArr[indexPath.item]
print(countrynameArr[indexPath.item])
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
myIndex = indexPath.row
let cell = tableView.cellForRow(at: indexPath)
countrynameArr[indexPath.row] = cell!.textLabel!.text!
print(countrynameArr[indexPath.row])
if shouldPerformSegue(withIdentifier: "segue0", sender: cell){
self.performSegue(withIdentifier: "segue0", sender: cell)
// tableView.deselectRow(at: indexPath, animated: true)
// self.tblView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.none)
}
}