Why use UIViewController?

Discussion in 'iOS Programming' started by Stratoukos, May 27, 2009.

  1. Stratoukos macrumors member

    Joined:
    Jul 15, 2008
    #1
    First of all let me clarify that I am not asking why to use a controller. I am just asking why to subclass UIViewController instead of just making my own controller (subclassing NSObject). I've read through the documentation and I haven't seen anything I need to inherit from it. My view won't load from a nib and it won't need to handle rotation. I am just asking since it's kinda de facto to use it.

    So, can I safely make my own controller or is there something I'm missing?

    Thanks.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Is your viewController going to load a view or have to deal with it appearing and disappearing? Is it going to need to respond to events? Cuz those things are also handled by the viewController.

    P.S. There is no UIObject. You probably meant NSObject, right?
     
  3. Stratoukos thread starter macrumors member

    Joined:
    Jul 15, 2008
    #3
    Whoops. Silly typo. I did mean NSObject. I edited my first post.

    Yep. There it is. I knew it was there for a good reason. Thanks for the really quick reply.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    You're welcome. When trying to determine if subclassing is for you, sometimes it helps to step through the hierarchy of the ancestors to see what you are getting as well. UIViewController < UIResponder < NSObject.
     

Share This Page