Hello I am new to the Objective C and I have a problem.
I have a View controller from where I call the level_1 of my game.
GameViewController *level1 = [self.storyboard instantiateViewControllerWithIdentifier:@"GameIdentifier"];
[self.navigationController pushViewController:level1 animated:YES];
It works fine.
… BUT I want to make two different levels (level_2 and level_3) using the same ViewController (GameViewController) (I will call them from the same class),
but I don’t know how to pass an argument (for example an int) to the GameViewController (that argument will be the current level, for example 2 or 3).
You need to add an instance variable (and some accessors to get/set it) to your GameViewController class, and then assign the level number to your “level1” or “level2” instances.
Here is some sample code, showing you how you should write your GameViewController class:
Then, you need to pass the level number to your view controller: