You need to set the variable of the second viewcontroller in the prepareforsegue method of the first. Here's how to do it:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([segue.identifier isEqualToString:segueIdentifier1]) { SecondViewController *secondVC = (SecondViewController *)segue.destinationViewController; if(sender.tag == ...)
Then you can check this property in the second vc to understand how you got there. If you created 2 segues in a storyboard for 2 buttons, then only the segue identifier is enough to set the corresponding property value. Then the code turns into this:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([segue.identifier isEqualToString:segueIdentifier1]) { SecondViewController *secondVC = (SecondViewController *)segue.destinationViewController; secondVC.identifyingProperty = ... } else if([segue.identifier isEqualToString:segueIdentifier2]) { SecondViewController *secondVC = (SecondViewController *)segue.destinationViewController; secondVC.identifyingProperty = ... } }
guenis
source share