I'm trying to set an Integer on another VC using prepareForSegue
method. I've got four buttons and each button has its own boolean value changed when pressed
- (IBAction)answerChoiceFourPressed:(id)sender {
self.ButtonFourPressed = YES;
}
I have got this method here:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
((SecondQuestionViewController *)segue.destinationViewController).delegate=self;
if ([segue.identifier isEqualToString:@"toQuestion2"]) {
SecondQuestionViewController *mdvc = segue.destinationViewController;
NSInteger newInt;
if (ButtonTwoPressed == YES) {
newInt = 1;
[mdvc setSecondScore:newInt];}
if (ButtonThreePressed == YES) {
newInt = 2;
[mdvc setSecondScore:newInt];}
if (ButtonFourPressed == YES) {
newInt = 3;
[mdvc setSecondScore:newInt];}
else {
[mdvc setSecondScore:0];}
}
}
In SecondQuestionViewController I've got it all covered:
#import "FirstQuestionViewController.h"
and the secondScore int is declared as a @property:
@property (nonatomic, assign) NSInteger secondScore;
I'm using NSLog (@"Score NUMBER 2 is %d", secondScore);
And it's always giving me 0, unless the fourth button is pressed: it gives me 3 (last one in prepareForSegue
method)
What is the possible problem?
Thanks in advance!