yosri hadi yosri hadi - 2 months ago 8
Swift Question

send from tableview didselect to seque to send other controlller

i have table get some things from json
whin i select the row indexof row i want to open other control
and other control get some varbiles for first one
imake the code
but in the code try to send from tableview to seque but in seque nothing happen what wrong in the code
i want to get url fro table

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath:
IndexPath)
{

// let selectedEpisode = self.episodes[(indexPath as NSIndexPath).row]



self.performSegue(withIdentifier: "videoplay", sender: indexPath);

}
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {

cell.alpha = 0
let transform = CATransform3DTranslate(CATransform3DIdentity, -250, 20, 0)
cell.layer.transform = transform
UIView.animate(withDuration: 1.0) {
cell.layer.transform = CATransform3DIdentity
cell.alpha = 1
}
}
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

if segue.identifier == "videoplay" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let selectedEpisode = self.episodes[(indexPath as NSIndexPath).row]
let yosrihh = selectedEpisode.url! as URL
let destination = segue.destination as! videoPlayViewController

destination.urll = yosrihh

}



}

}

Answer

The issue is that in Swift 3 prepareForSegue(:sender:) is changed to prepare(for:sender:), so just change the method like this then all set to go.

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    //Your code
}
Comments