I have prototype cell and in this cell there is an UIButton; so I need to perform a segue from the button to other controller, not from the cell. I tried to create an Outlet @IBOutlet var button: UIButton!
and use performSegueWithIdentifier() method
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
self.performSegueWithIdentifier("toSecondController", sender: button)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
but I have no idea how to set the prepareForSegue() method... i tried this
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if segue.identifier == "toSecondController"
{
if let indexPath = sender as? UIButton//tableView.indexPathForSelectedRow()
{
let controller = segue.destinationViewController as! CoriViewController
controller.coriSquadra = DataManager.sharedInstance.arrayCori[indexPath.row]
}
}
}
I also read that a solution would be implement a protocol, but I'm a beginner and I need a step by step guide. Hope someone can help me!