How to Send data between view controllers StoryBoard Xcode

storyboard, uiviewcontroller, xcode

Solution

Use this method to pass the property in all of your view controllers

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"ShowNewVC"]) {
        NextViewController *nextVC = (NextViewController *)[segue destinationViewController];
        nextVC.someProperty = self.myProperty;
    }
}

Change the name of "NextViewController" to match yours. Be sure to add the "Segue Identifiers" in your Storyboard file.

This should work. However, when you have to pass this property trough so many view controllers, you can consider creating a Singleton "Data Manager" object to store the data. The View Controllers would have access to the data through the singleton.

Good luck!

Problem

Please help me.. I want to pass data between different controllers in storyboard. For Example. First View Controller ``` NSString *firstValue; firstValue = @"First Number"; ``` Now I want to send this to the result view controller and store in ``` NSString *resultFromFirstVC; ``` and show in label. ``` [label setText: resultFromFirstVC]; ``` so the label show: First Number

Original source