1

I'm looking for a way to pass arguments from view controller to another. For example:

I've designed one view controller that receives username and password, and has a submit button which leads to another view controller, which I've designed in main.storyboard. The connection between the controllers is by dragging the button to the second view controller and choosing 'modal' in the connection type.

How can I transfer the user details to the second view controller?

NobodyNada
  • 7,529
  • 6
  • 44
  • 51
Liran Revivo
  • 1,143
  • 3
  • 15
  • 20
  • See this one here: http://stackoverflow.com/questions/8597025/how-do-i-pass-information-between-storyboard-segues – mitrenegade Aug 19 '14 at 20:19

1 Answers1

0

You'll need to use prepareForSegue:sender: method. As taken from https://stackoverflow.com/a/7865100/657676:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
        // or
        vc.property = value;
    }
}
Community
  • 1
  • 1
Joseph Duffy
  • 4,566
  • 9
  • 38
  • 68