My scenario, I am trying to pass the value from ViewController B to ViewController A during dismiss the view controller. Here I used below code but I can’t able to get the value in ViewController A.
ViewController B
// protocol used for sending data back
protocol isAbleToReceiveData {
    func pass(data: String)  //data: string is an example parameter
}
// Making this a weak variable so that it won't create a strong reference cycle
var delegate: isAbleToReceiveData?
override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(true)
        self.delegate?.pass(data: "someData") //call the func in the previous vc
}
@IBAction func Click_action(_ sender: Any) {
        self.dismiss(animated: false, completion: nil)
        self.delegate?.pass(data: "someData") 
 }
ViewController A
class MyViewController: UIViewController, isAbleToReceiveData {
func pass(data: String) {
        print("USER: \(data)")
    }
}
// MARK: FromTouch Action
    @objc func fromTouchTapped(_ sender: UITapGestureRecognizer) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "ViewControllerB")
        viewController.modalTransitionStyle = .crossDissolve
        let navController = UINavigationController(rootViewController: viewController)
        present(navController, animated: true, completion: nil)
    }
 
     
     
     
    