문제

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;  

    } 
}
도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top