Resolved Where to put the outlets...

Discussion in 'iOS Programming' started by grandM, Aug 15, 2015.

  1. grandM macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #1
    In doubt: I added a view B inside the main view of a ViewController C. Upon creating the outlets I connected them to the ViewController C. It is obvious the UIView outlet for view B ought to be placed in the ViewController C. But the outlets which are in view B should they be in ViewController C. Or should a new ViewController be added containing the outlets of view B?

    Everything works by the way. I just want to know if I made a design mistake placing the outlets in the ViewController C.
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    There's no reason to add a child view controller just for the purpose of holding the outlets. In general the outlets will go in the owning view controller regardless of how deep the view hierarchy is. In some cases outlets would go in a parent view (not view controller). Properties in UITableViewCell are like this.
     
  3. grandM thread starter macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #3
    Oh thanks. So basically I do not need to add an extra ViewController. I did wonder if it wasn't a sign of better programming. Would have complicated matters though. I was already wondering how I would pass the property from the parent ViewController to the child ViewController. Would this be have been done with a protocol and delegate?
     
  4. grandM thread starter macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #4
    Oh thanks. So basically I do not need to add an extra ViewController. I did wonder if it wasn't a sign of better programming. Would have complicated matters though. I was already wondering how I would pass the property from the parent ViewController to the child ViewController. Would this be have been done with a protocol and delegate?
     

Share This Page