I have created a custom TableViewCell
and currently have a button placed in the cell. When the button is pressed, In the tableviewcell.swift
file, IBAction func
gets executed. I cannot figure out how to determine the index path of the cell that the button is in that is pressed. I was trying to use the following
@IBAction func employeeAtLunch(sender: AnyObject) {
let indexPath = (self.superview as! UITableView).indexPathForCell(self)
println("indexPath?.row")
}
but I get the following error on click:
Could not cast value of type 'UITableViewWrapperView' to 'UITableView'
Any help on how to access the index path of the cell?
See Question&Answers more detail:os