There is one controller, for example, "C" , which can be reached from two places "A" and "B" .
Transitions in the storyboard assigned identyfire , for example, "iA" and "iB" , but when moving from А you need to perform an additional method.

The question is: how to track which controller c is making the transition to "C" , and what would the if condition look like to call an additional method?

    1 answer 1

    As an option, make your Bool property in your "C" controller, then in controllers "A" and "B" in the prepareForSegue method prepareForSegue set the value for this property to YES/NO

    Objective-C:

     - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"MySegue"]) { // Получаем контроллер CController *vc = [segue destinationViewController]; // устанавливаем значение [vc setYourBoolProperty:YES]; } } 

    Swift 2.2

      override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) { if segue!.identifier == "MySegue" { let nav = segue.destinationViewController as! UINavigationController let viewController = nav.topViewController as! СController viewController.yourBoolProperty = true } } 

    Well, then perform the necessary actions in the if-else

    • thanks for the good idea! integrated it into a project and get an error of such a plan: Could not cast value of type 'UINavigationController', and in the code the creation line let viewController is highlighted in red: VC = segue .... - pbogdanv
    • Do this: let nav = segue.destinationViewController as! UINavigationController let viewController = nav.topViewController as! СController let nav = segue.destinationViewController as! UINavigationController let viewController = nav.topViewController as! СController let nav = segue.destinationViewController as! UINavigationController let viewController = nav.topViewController as! СController . Changed answer - Vitali Eller