How do I pass information between storyboard segues?

13,278

Use the prepareForSegue:sender: method to pass data from the source to destination view controller:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:...]) {
        MyViewController *controller = (MyViewController *)segue.destinationViewController;
        controller.myProperty1 = ...;
        controller.myProperty2 = ...;
    }
}
Share:
13,278
Carl Goldsmith
Author by

Carl Goldsmith

Updated on June 17, 2022

Comments

  • Carl Goldsmith
    Carl Goldsmith about 2 years

    In the app I'm creating, one of the features is that users can submit their own quotes to be displayed in the app. There is one storyboard segue that lets the user enter their name, email and website, and then on the next they type in a quote and the app then posts all of this data to a database. I'm not sure how I can easily pass data from the first storyboard segue to the next, so that it can post all of the information to the database in one go. Thanks in advance for any replies.

  • Deb
    Deb about 10 years
    How to access it in the destination view controller?