0

In the application I can go from screen A to B to C. Also I can go from screen A to E and also I can go from screen C to E.

I want to know the entry point from where Controller E is presented.

PS : application is storyboard less and can’t post code due to confidentiality.

App is in Swift 3. Looking for some suggestions.

Shruti
  • 1
  • 13
  • 55
  • 95
  • What do you mean by the entry point? – Sweeper Feb 28 '18 at 06:39
  • I mean by entry point that if controller E is launched by controller A or C. So entry point for Controller E is A or C. – Shruti Feb 28 '18 at 06:40
  • @Shruti : You want top root view controller which is loaded from UIWindow? or you want last view controller which is presented current viewcontroller? – Ankit Chauhan Feb 28 '18 at 06:48
  • 1
    Possible duplicate of [Reference to the segue source view controller](https://stackoverflow.com/questions/16846760/reference-to-the-segue-source-view-controller) – staticVoidMan Feb 28 '18 at 06:54
  • @AnkitChauhan I want the last view from where this current view controller is presented – Shruti Mar 10 '18 at 05:20

2 Answers2

1

why dont you just use the parent property of E viewController and check the source that presented it you can do something like

           if let parentController = self.parent as? A {
           //do smething
           }
           else if let parentController = self.parent as? C {
           //do smething
            }
Geet
  • 2,427
  • 2
  • 21
  • 39
0

The most simple way is to pass some data in your segue

i.e.

if segue.identifier == "showDest"{
let destVc = segue.destination as! YourViewController
destVC.source = currentVC
}
stevenpcurtis
  • 1,907
  • 3
  • 21
  • 47