I am trying to pass the score from my game part to the scoreboard. However, i cannot seem to do it. This is my code in my GameViewController
.
- (void)gameHasEnded {
ScoreViewController *scoreVC = [[ScoreViewController alloc] initWithNibName:@"ScoreVC" bundle:nil];
scoreVC.score = scoreAsString;
NSLog(@"%@",scoreVC.score);
[self performSegueWithIdentifier:@"continueToScore" sender:self];
}
This is my code in my ScoreViewController
.
- (void)viewDidLoad {
[super viewDidLoad];
self.scoreLabel.text = scoreString;
NSLog(@"Score = %d", self.score);
}
In the log it shows the correct score before it performs the segue. However, once in the ScoreViewController
it gives a null value. I referred to Passing Data between View Controllers but it did not work for me. Why does it not work for me? Is there something wrong with the code or did i miss out on something in the code?