I have attempted to pass an Integer value using a Segue from one view controller to another. I used this thread to help me: Passing Data between View Controllers.
So I followed the steps from the top question, declared my integer in the view controller that is receiving the info's header, and likewise imported that header into the view controller that is sending the info's header. I created a modal segue that I though would both create the integer's value and present the second view controller. It only presents the second view controller. In addition when I close my app it freezes my whole phone!
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"useCheat"]){
begin *controller = (begin *)segue.destinationViewController;
// I get a warning report here that says, "unused variable 'controller'". I could not figure out a fix.
if (codeForAllActive == YES) {
score = 10;
}
else if (codeForOneActive == YES) {
score = 9999975;
}
}
}
As you can see, useCheat is the segue identifier. begin is the view controller receiving the info. (the info is the value of score). The value of score does not change in begin.
If I do this 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 get an error at controller.score
that reads: property score not found on object type begin.
So in begin.h (begin is the destination VC) I create a property for score:
@property(strong,nonatomic) NSInteger score;
Once I do that, I get this error: unexpected '@' in program. I took out the '@' and I get another error: missing parameter score.