I am trying to call a prepareForSegue
function out of TableViewController
from a button in an UITableViewCell
.
Can I just call it from the button? Something like:
TableViewcontroller:
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "segueExercise") {
print(segue.identifier)
let vc = segue.destinationViewController as! DetailViewController
TableViewCell:
@IBAction func exerciseAction(sender: UIButton) {
ViewController.prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!)
}
Would it be too easy, or am I missing something ?
Solved. I passed the index via
UIButton
optiontag
and replaced theindexPathForSelectedRow
.