ios - Passing data from one UITableView to another UITableView inside didSelectRow? -


there 2 uitableviews, first 1 has cell when tapped, opens second uitableview. when cell in second uitableview selected, second tableview screen should dismiss , carry text cell , populate label in first uitableview's cell label. code have far follows , gives threading error:

func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) {     let destvc = enrollmentaccounttableviewcontroller()     destvc.lblaccounttype.text = globalparams.enrollmentaccounttypes[indexpath.row].acctname      self.navigationcontroller?.popviewcontroller(animated: true) } 

try :-

 func tableview(_ tableview: uitableview, didselectrowat indexpath:   indexpath) {    obj in (self.navigationcontroller?.viewcontrollers)! {         if obj enrollmentaccounttableviewcontroller {  let vc2: enrollmentaccounttableviewcontroller =  obj as! enrollmentaccounttableviewcontroller   vc2.straccname = globalparams.enrollmentaccounttypes[indexpath.row].acctname             _ =   self.navigationcontroller?.poptoviewcontroller(vc2, animated: true)  break         }     }     } 

in enrollmentaccounttableviewcontroller

var  straccname:string!  override func viewwillappear(_ animated: bool) {  if  straccname !=  nil {   self.lblaccounttype.text =  straccname   }   } 

Comments