Complete newbie here, and I'm trying to make a button from a tabelViewCell display its row number when pressed.
Here's the code from tableViewCell:
var myTableViewController: tableViewController?
@IBOutlet var addButton: UIButton!
@IBAction func addButtonPressed(_ sender: Any) {
myTableViewController?.addCellToHome(self) //call add function
}
And from tableViewController:
func addCellToHome(_ cell: UITableViewCell) //specifies what is to be done when addButton is pressed
{
let row = tableView.indexPath(for: cell)
print(row as! String)
}
Can someone please tell me what I'm doing wrong? I inserted a breakpoint inside addCellToHome and turns out it's never called. Completed stumped.
Thanks in advance.