application schema

Hello everyone! I want to process a click on a cell using override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) The difficulty is that I do not quite understand how to access data on another controller. That is, when I click on the tableView cell, I want to take the data from the Name field (UILabel) and transfer it to another controller in the uchLabel field (UILabel). How can this be done?

  • How to transfer the data I understood (performSegueWithIdentifier). But how to take them later? - Ivan
  • Recently asked a similar question, look, it can help: bit.ly/2aTTeaT - Gikas

2 answers 2

If you have already created a segue in the storyboard (Do not open the detail controller twice)

 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "Detail" { let destVC = segue.destinationViewController as! UchastokViewController destVC.yourPropepry = String(sender) } } 

In case, if you have not created segue in the segue (Show Detail)

 override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { performSegueWithIdentifier("ToDetail", sender: loans[indexPath.row].title) } 

This will allow you to "walk" without explicitly indicating the segue in the storyboard.

     override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "ToDetail" { let DestinationVC = segue.destinationViewController as! UchastokViewController DestinationVC.uchTitle = String(sender) } } override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { performSegueWithIdentifier("ToDetail", sender: loans[indexPath.row].title) } 
    • However, now my viewController opens 2 times. Can anyone suggest why? - Ivan