UITableView - Seque

uitableview

#1

Есть таблица с названием товаров, изображениями и ссылкой на товар на сайте
На 1 экране сама таблица, на втором экране - описание товара c картинкой, а на третьем экране - WebView с открытием товара на сайте

Как сделать чтобы при открытии ячейки передавались данные в webView с нужной ссылкой на товар?

class Assortiment: UITableViewController {
    
    let imageNameArray = ["Постельное белье",
                          "Покрывала)"]
    let imageNameArray2 = ["https://maisondore.ru/postelnoe-belie/",
    "https://maisondore.ru/pokryvala/"]

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    // MARK: - Table view data source

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return imageNameArray.count
    }


    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Title", for: indexPath)
        
        cell.imageView?.image = UIImage(named: imageNameArray[indexPath.row])
        cell.textLabel?.text = imageNameArray[indexPath.row]
        cell.textLabel?.numberOfLines = 0

        return cell
    }
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60
    }


    // MARK: - Navigation

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "Show Detail" {
            if let indexPath = self.tableView.indexPathForSelectedRow {
                let detailsVC = segue.destination as! DetailsVC
                detailsVC.trackTitle = imageNameArray[indexPath.row]
            }
        }
    }


}

#2

detailsVC.trackUrl= imageNameArray2[indexPath.row]

а дальше уже из 2о экрана передаете этот урл в 3й экран

P.S. лучше всего для таких случаев передавать модель объекта целиком


#3

спасибо! мега оперативно прям)


#4

а не подскажите ли есть ли на swiftbook видеоурок по передачи модели объекта целиком?


#5

Да, и он бесплатный Курс: Основы Программирования
Конкретно 25 урок.