ios - Return array to another ViewController in Swift -


i have 2 uiviewcontrollers , each 1 has uitableview. lets when call view-a view-b, take cells marked in uitableview in view-b and, after pressing button want return array data selected view-b view-a, dismiss view-b , represent information in tableview of view-a. how can pass array ? how have reaload data in view-a show after dimissing view-b ?

any idea? thank much!!

protocol datapasserdelegate {    func senddatatoa(dataarrayfromb : array<anyobject>) }  class viewb: uiviewcontroller {  var delegate: datapasserdelegate!  var dataarrayb = array<anyobject>()  @ibaction func senddata(sender: any){     self.dismiss(animated: true) {          self.delegate.senddatatoa(dataarrayfromb: self.dataarrayb)     }  } }  class viewa: uiviewcontroller, datapasserdelegate {  @iboutlet weak var tableviewa: uitableview!  var dataarraya = array<anyobject>()  //mark: - datapasserdelegate func senddatatoa(dataarrayfromb: array<anyobject>) {     dataarraya = dataarrayfromb      self.tableviewa.reloaddata() }  override func prepare(for segue: uistoryboardsegue, sender: any?) {     if let destvc = segue.destination as? viewb{         destvc.delegate = self     }  } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -