View controllers are a essential part of managing your app ' s. View controllers allow you to break your apps up into multiple parts and instantiate only the parts that are. But more than that, the A view controller itself manages different resources and instantiates them in different times. For example, a view controller ' s view hierarchy be instantiated only when the view is accessed; Typically, this occurs the ' view ' is displayed in screen. If multiple view controllers are pushed onto a navigation stack at the same time, only the topmost view controller ' s Conte NTS are visible, which means only it views are accessed. Similarly, if a view controller is isn't presented by a navigation controller, it does not need to instantiate its navigatio N Item. By deferring most resource allocation until it are needed, view controllers use less resources.
The view controller is an important part of managing application resources. The view controller allows you to spread applications to different parts, only to sample them when needed. In addition to this, the view controller itself manages different resources and instantiates them at different times. For example, the view hierarchy of a view controller is instantiated only when the view is fetched (usually when the view is displayed to the screen). If multiple view controllers are pushed into the navigation stack at the same time, only the view controlled by the topmost view is visible, which means that its view can be accessed. Similarly, if the navigation controller does not display a view controller, the view controller does not need to instantiate the navigation item. Allocate resources When you know it is needed, so that the view controller can save memory.
When memory available to the app runs low, all view controllers are automatically by the system. This allows the view controller to purge caches and other objects then can be easily recreated later when memory are more p Lentiful. The exact behavior varies depending on which version of IOS your app be running on, and this has implications for your Vie W controller design.
The system automatically notifies all view controllers when the application of available memory is low. This allows the view controller to clear the cache, as well as other objects that can be recreated when memory is abundant. These features are associated with the iOS system.
Carefully managing the associated with your view controllers-critical to making your app run efficiently. You should also prefer lazy allocation; Objects that are expensive to create or maintain should is allocated later and only when needed. For this reason, your view controllers should separate objects needed throughout the lifetime of the View controller from Objects that are only necessary some of the time. When your view controller receives a low-memory warning, it should being prepared to reduce its memory usage if it isn't vis Ible onscreen.
Running a program effectively requires careful management of the resources associated with the view controller. You should be lazy to load. For expensive objects to be created or retained, they are loaded only when they are needed. Therefore, the view controller distinguishes between objects that are needed throughout the controller lifecycle and objects that are only needed at some point in time. When the view controller receives a memory warning, it should be prepared to reduce the use of memory if it is not visible on the screen.