Simple iOS Viewstack29 May 2013
Posted by : Gareth Shapiro
One of the central mechanisms in the architecture of an iPhone or iPad app is a UINavigationController, there is at least one in most apps. This class is similar to a view stack found in other application frameworks and for the most part works very well. One drawback, and this has as much to do with iPhone and iPad application architecture as it does the UINavigationController itself, is the decentralised approach to navigating between children UIViewControllers. Not having details that relate to one aspect or your application, in this case navigation, in one place in your code can make things hard to find and this frustrating situation can be made more so by the use of storyboards, but that's another conversation entirely.
The situation can very easily be improved ...
SimpleIOSViewStackController is an Objective-C utility which extends UINavigationController providing two significant improvements.
- Details about UINavigationController's children UIViewControllers, can all be found in one place. This makes it much easier to the code where changes to current application view occur and delivers an added benefit of being able to start your app in a particular view state. This becomes a great production benefit later in a project, helping to remove the need to click through several screens to get to the one you are wanting to test.
- Moving from one UIViewController to another is as simple as dispatching an NSNotification, from anywhere in your application. Application notifications are distributed, as they should be, instead of details regarding the view, and UIViewController, hierarchy.