Question

Is it possible to pass the value of a double (for example) through a Segue? Given the sample code, I'm trying to pass the value of a UIStepper (a double) through the Segue to another view. I know I have to declare the double on the other controller, but I'm not sure if this is even possible. What do I have to declare in the other View Controller to make this work?

Thanks in advance.

-PaulS.

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"home2Segue"]) 
    {
        double classLength = stepperClassTime.value;

        home_1_ViewController *vc = (home_1_ViewController *)[segue destinationViewController];

        vc.classLength = classLength;  

    } 
}
Was it helpful?

Solution

That should work fine if you add classLength as a property in your home_v1_ViewController class:

Header file (.h):

@property (nonatomic) double classLength;

Implementation file (.m):

@synthesize classLength;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top