ios - Passing data between View Controllers using segues. Not working -
i have attempted pass integer value using segue 1 view controller another. used thread me: passing data between view controllers.
so followed steps top question, declared integer in view controller receiving info's header, , likewise imported header view controller sending info's header. created modal segue though both create integer's value , present second view controller. presents second view controller. in addition when close app freezes whole phone!
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ if([segue.identifier isequaltostring:@"usecheat"]){ begin *controller = (begin *)segue.destinationviewcontroller; // warning report here says, "unused variable 'controller'". not figure out fix. if (codeforallactive == yes) { score = 10; } else if (codeforoneactive == yes) { score = 9999975; } } }
as can see, usecheat segue identifier. begin view controller receiving info. (the info value of score). value of score not change in begin.
if instead:
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ if([segue.identifier isequaltostring:@"usecheat"]){ begin *controller = (begin *)segue.destinationviewcontroller; if (codeforallactive == yes) { controller.score = 10; } else if (codeforoneactive == yes) { controller.score = 9999975; } } }
i error @ controller.score
reads: property score not found on object type begin. in begin.h (begin destination vc) create property score:
@property(strong,nonatomic) nsinteger score;
once that, error: unexpected '@' in program. took out '@' , error: missing parameter score.
try following code
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { secondviewcontroller * secondvc = (secondviewcontroller *) segue.destinationviewcontroller; secondvc.intvariable = 10; }
Comments
Post a Comment