简体   繁体   中英

How to access variables from main storyboard scene in other storyboard scenes?

I am developing an app that has 3 storyboard scenes. In the first storyboard scene, I have some variables that I want to access in other two scenes. How can I do it? I navigate to other two scenes using Storyboard segue and calling the following on button click

[self performSegueWithIdentifier:@"nameofsegue" sender:self];

Use this method

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"nameofsegue"]) {
        YourDestinationVC *dvc = [segue destinationViewController];
        YourSourceVC *svc = (YourSourceVC*)sender;
        //set your ivr here
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM