Reputation: 51
At the moment i have 9 game levels. After you complete the first game you go to results screen. After you press continue the results screen goes to second game and this continues until last game. I wanted to know if there is a way to make it so that after you press continue in the results screens it will go to random game level(or view controller). Sorry if my terminology is bad but i just started coding with objective-c and not sure if what im asking is possible without having to make a lot of segues for each level(view controller).Now i have 20 view controllers in my story board. 1.Intro screen. 1.Name submitting screen. 9. game levels and 9 corresponding result screens.
Upvotes: 0
Views: 85
Reputation: 1412
Why don't you keep reference to your viewControllers
in an NSArray/NSSet
and once you want a random viewController select a random index with:
arc4random();
Or if you don't want to init all the viewControllers
at the start, you can create a set index to every viewController
, and once the index is chosen you can init the matching viewController
Upvotes: 2