If inside my app, I can push like this (A, B and C represent some view controllers): A -> B -> C -> B -> C -> B ....., this can go forever, is this an acceptable design pattern?
This may seem a silly and obvious question but I have this app called "Taobao" (China's biggest, most famous online shopping app) from Alibaba Group (owned by China's richest man), it is exactly like what I described above. In the app I can go like A -> B -> C -> B -> C -> B .....then if I need to go back to A I need to go back as many times as I go deeper, which means all view controllers are pushed on the stack during the navigation.
Since Alibaba Group is a very trusty tech company so I believe this navigation pattern is there for a reason. My common sense tells me it is not a good pattern but I want to hear from you experienced guys. Thanks!
Generally you can push anything which makes sense for your app. There is just one (pretty obvious condition) - do not push controller which is on top of your stack.
But there is a big BUT! If your stack can be really infinite you have to keep in mind that navigationcontroller stack is stored in memory! Adding more and more controllers on the stack without releasing any of them will end up, sooner or later, with memory crash. That's why you cannot use just simple pushViewController method. You can reconsider setViewControllers along with some other helpers to keep your stack at reasonable size. Or limit it to specific number based on memory usage observation. I believe there are plenty of options but that growing memory is a point which you should keep in mind.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments