Passing Data Between Segue

Discussion in 'iOS Programming' started by w3tmb, Feb 7, 2013.

  1. w3tmb macrumors newbie

    Joined:
    Feb 7, 2013
    #1
    I have a application that is a quiz with a few UI I want to keep track of how many questions a person gets correct how can I set a variable that can be used in all my UI's all I need is a simple INT. Sorry if this question seems stupid but before last week I never have worked in xcode.

    THanks
     
  2. hollersoft macrumors member

    Joined:
    Feb 10, 2013
    #2
    In your parent ViewController you implement prepareForSegue. A parameter to that call is the UIStoryboardSegue object. You can get the destination view controller from that object and call methods to pass whatever data you need.

    Code:
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue.identifier isEqualToString:@"MySegueName"])
        {
            MyDestinationViewController *vc = segue.destinationViewController;
            vc.myParameterIWantToSet = whatever;
        }
    }
     

Share This Page