Return array to another ViewController in Swift

I have two UIViewControllers and each one has an UITableView. Lets say that when I call from View-A to View-B, I take the cells which are marked in the UITableView in View-B and, after pressing a button I want to return an array with all the data selected from View-B to View-A, dismiss View-B and represent that information in the TableView of View-A.
How can I pass that array ? How do I have to reaload the data in View-A to show it after dimissing View-B ?

Any idea?
Thank you very 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
    }
 }
}

So you can use prepareForSegue:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
    if (segue.identifier == "segueID") {
        if let controller = segue.destination as? YourVC{
            controller.array = yourArray
            controller.tableView.reloadData()
        }
    }
}

You will need to use delegate for this. For more information on delegates you can go through my blog here.

you had better to use protocol method

protocol SelectedRowsProtocol {
func getSelectedRows(array:[Int])
}

class SecondViewController: UIViewController {

var delegates : SelectedRowsProtocol?

func dismissView(){
      self.delegates.getSelectedRows(array: selectedArray )
      self.dismiss(animated: true, completion: nil)
    }
}

in firstViewController

class FirstViewController: UIViewController, SelectedRowsProtocol {
      override func viewDidLoad() {
        super.viewDidLoad()

      }

  func getSelectedRows(array:[Int]){

     let x = array
  }
}

You want to set secondViewController.delegates = self where you given to present the secondViewController