Wednesday, 16 May 2012

Design Patterns and View Controllers

          Types of Design Patterns
    • Singleton
    • Delegation
    • Model View Controller       
           Singleton
           The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. 
           Ensure a class has only one instance, and provide a global point of access to it.
           Delegation
           A delegate is a type that references a method. Once a delegate is assigned a method,it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value.Delegates are declared using the keyword delegate.
    Note:Once instantiated, the delegate reference can be used directly as a method
           Model View Controller
           Model View Controller: In the Model-View-Controller (MVC) design pattern, a controller object provides the custom logic needed to bridge the application’s data to the views and other visual entities used to present that data to the use.  


      
  • View controller should encapsulate all of the behavior associated with managing the views in its view hierarchy.
  • Each view controller is responsible for managing a discrete part of your application’s user interface.
  • The view controller  acts  as the central coordinating agent for the view hierarchy, handling exchanges between its views and any relevant controller or data objects.
  • A view controller is a specific type of controller object that you use to present and manage a set of views.
    • View controller objects are descendants of the UI View Controller class, which is defined in the UIKit framework.
    • A view controllers provide a vital link between an application’s data and its visual view. 

      View Controller Class

    • View controller classes available in the UIKit framework along with some of the key classes used in conjunction with view controllers.
    • These classes are often used internally by view controller objects to implement special types of interface 

              Types of View Controller

            1. Custom View Controller
            2. Table View Controller
            3. Container View Controllers
                      i. Navigation Controller
                      ii.Tab Bar Controller
                      iii.Split View Controller
            4.Window based View Controller
           
          Custom View Controller
           Each custom view controller object you create is responsible for managing all      single view hierarchy.
           Table View Controller
           The UI Table View Controller  class is another  type of custom view controller designed specifically for managing  tabular  data.The class adds automatic support for many standard table-related behaviors such as selection management, row editing, table configuration, and others.
           Navigation Controller
           The navigation template provide a starting point for an application that uses a navigation controller .It provide a user interface configuration with navigation controller to display a list of item.Navigation controller’s primary job is to act as a manager of other view controllers.It also manages a few views. Specifically, it manages a navigation  bar that displays information about the user’s current location in the data hierarchy, a back button for navigating to previous screens, and any custom controls the current view controller  needs.The navigation controller also manages an optional toolbar, which can be used to display commands related to the current screen.
           Tab Bar Controller
           A tab bar controller is a container view controller that you use to divide your application into two or more distinct modes of operation  
           Split View Controller 
              Split template provide a starting point for an application that uses a split view controller.It provide user interface configuration with a split view controller and two view controller to manage a master detail style view.A split-view controller is a container  view controller that is typically used to implement master-detail interfaces Split-view controllers are supported on iPad only.
          Window based View Controller
           Window based view controller provide application delegate and window.

     

1 comment: