ios - TableView Cell Tapped Returning Nil in Segue -


i'm trying pass table view information view controller , getting "fatal error: unexpectedly found nil while unwrapping optional value". here code.....

  func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath)     {         self.resultstableview.deselectrowatindexpath(indexpath, animated: true)          dispatch_async(dispatch_get_main_queue()) { () -> void in             self.performseguewithidentifier("playersegue", sender: self.resultstableview)         }      } 

and...

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     if segue.identifier == "playersegue"     {         let index = resultstableview.indexpathforselectedrow!.row         let controller = segue.destinationviewcontroller as! videoviewcontroller         controller.vidtitlelbl.text = self.videotitle[index]         controller.videoid = self.videoid[index]      } } 

it's not showing information @ indexpath.row. cell custom uitableviewcell , videotitle , videoid coming array of youtube json items.

you made harm doing self.resultstableview.deselectrowatindexpath(indexpath, animated: true) before perform segue.

after deselect row, asynchronously perform segue. when prepareforsegue method called, resultstableview.indexpathforselectedrow nil already, because deselected selected row.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -