0

I have a ViewController that I am presenting currently.

So lets say VC2 is being presented on VC1. Without Subclassing VC2 is there a way to be notified on VC1 that VC2 got dismissed? I don't want to create a subclass of ViewController just to acknowledge the dismissal of the ViewController for tracking purpose.

Thanks.

topgun
  • 2,253
  • 7
  • 28
  • 44
  • On `VC2`, you can get `VC1` by using `self.presentingViewController` and do whatever you want. – trungduc Apr 24 '18 at 18:10
  • Possible duplicate of [Detect when a presented view controller is dismissed](https://stackoverflow.com/questions/32853212/detect-when-a-presented-view-controller-is-dismissed) – koen Apr 24 '18 at 19:27

1 Answers1

0

You can try in VC1

var count = 0

 override func viewWillAppear(_ animated:Bool) {
   super.viewWillAppear(animated)
   count+=1

    if(count == 2) {
       // dismiss of VC2
    }

 }
Sh_Khan
  • 86,695
  • 6
  • 38
  • 57