I need to transfer data to another TableView at the click of a button, but I don’t understand how to do it
You need to pass the data to another TableViewController and save it in a variable.
I must pass an array of data
import UIKit
class DivanCell: UITableViewCell {
var favFurniture: Furniture?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
@IBOutlet weak var divanNameLabel: UILabel!
@IBOutlet weak var divanPhoto: UIImageView!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var sizeDivan: UILabel!
@IBOutlet weak var favButton: UIButton!
@IBAction func favTapped(_ sender: Any) {
favButton.setImage(UIImage(systemName: "heart.fill"), for: UIControl.State.normal)
favTapped()
}
func favTapped() {
favFurniture = (Furniture(name: divanNameLabel.text!, type: "Divan", image: divanPhoto.image!, price: priceLabel.text!))
FavouriteTableViewCell().favFurniture = favFurniture
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
into this tableview
class FavouriteTableViewCell: UITableViewCell {
var favFurniture = Furniture?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}