I'm building an app with a UINavigationController where I push a UIViewControllers, and IBActions on one of the classes can cause another instance of the first type to be pushed:
ViewControllerType1 --> ViewControllerType2 --> ViewControllerType3 --> ViewControllerType1
As you can see, its possible to have no 'end' to the stack.
Is this bad practice to have a never ending cycle like this? Should a UINavigationController stack be used with an 'end' in mind?
It's fine to allow a "cycle" if that's what the user expects.
If you expect (and want to allow) the user to create deep stacks, you should try to minimize the amount of private state in each view controller. For example, if two view controllers on the stack both show the same information to the user, you should make both view controllers share the same underlying object holding that information.
You should also make sure each view controller releases as much as it can if it receives the didReceiveMemoryWarning
message (if that view controller is not on top of the stack).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With