tableview - How to send didSelectRowAtIndexPath back to view controller in swift -
I have 1 view controller and 1 table view controller fast. I can send a NSMutableArray from ViewController to populate the ViewController table using segue. I do not know how to send the selected row back to the view controller. Code so far:
  Override function table view (Table view: UITableView, didSelectRowAtIndexPath index: Path: NSIndexPath) {println ("You selected cell # \ (indexPath.row)!") // Code    Any ideas?   
 
   Itemprop = "text">  You can use the delegation pattern Protocol Create a property:  
  Protocol MyDataDelegate {didSelectRow (line: NSIndexPath, data: MyData)} In the table controller, add a property:  < pre>  MyDataDelegate: MyDataDelegate? Call the delegate method in    and  didSelectRowAtIndexPath  call:    overcoded function tableview (table view: UITableView, didSelectRowAtIndexPath index path : NSIndexPath) {Println ("You have selected cell # \ (indexPath.row)!") Data = getDataForRow (indexPath) // & lt; == You need to implement yourself. MyDataDelegate? .didSelectRow (indexPath, data: data) auto In your main view controller:   -  Apply 
 MyDataDelegate  protocol     / li> -  Apply the MyDataDelegate.didSelectRow method  
 -  Before you submit the table controller (or after creating it, if you do it manually), set the 
 myDataDelegate  property to yourself Table Controller    In this way, when a line is selected in your table controller, then  didSelectRow  It is said on the block, so that whatever you want with the index path and / o   definitely  didSelectRow  sign (indexpath, or a line index, with data or Without use, etc.) Feel free to change    
 
  
  
Comments
Post a Comment