Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

w3tmb

macrumors newbie
Original poster
Feb 7, 2013
1
0
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
 

hollersoft

macrumors regular
Feb 10, 2013
100
64
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;
    }
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.