1
votes

I'm building an application with a non-linear path between multiple (but repeated) view controllers. For example, the first time I click "next" from ViewController1, I go to ViewController2. Then I click "next" and go from ViewController2 back to ViewController1 (with different data passed into ViewController1). Then I click "next" and go from ViewController1 to ViewController3.

How and where should I write this "path" logic?

How and where should I write the "differentiate view controller input data based on where I am in the path" logic?

My initial thought is to subclass UINavigationController and have it contain an array of view controller data constructors for my path (ie [VC1, VC2, VC1, VC3], with each object as a view controller constructor, not an actual view controller). When a user clicks "next", the NavController pops that view controller, calls a delegate method that the UINavigationController subclass handles by pushing the next VC in the array (with the correct data). "Back" would just go backwards in the array.

1

1 Answers

0
votes

you would have to write the code for passing data and creating the new VC on the next button action. you will have to break the pieces into separate vc. or you can use segues.