How can I pass a variable through a segue?
-
11-12-2019 - |
문제
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;
제휴하지 않습니다 StackOverflow