Will This Work

Discussion in 'iOS Programming' started by macprogrammer80, Oct 9, 2009.

  1. macprogrammer80 macrumors newbie

    Apr 22, 2009
    I have a view which is my "central window", which is controlled by a view controller. Within this view is a UITableView which I want to be controlled by a separate view/UITableView controller, so all of the table's data comes from a file other than what's managing the central window.

    I have an "Object" dropped from the Library into the window in Interface Builder with File's Owner in it. That Object's class is set to my other table view controlling file, and I make the connections in IB to my table view.

    When I run the app it loads fine, but it crashes as soon as I try and do anything.

    Is there a better way of doing this, or have I missed something?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Although not overly clear from the docs Apple doesn't really support multiple view controllers active in the same view at the same time. While I think its possible to make that work Apple explicitly recommends that you don't do it.

    The recommended way is to have one view controller that controls a screen. You would add your table view callbacks to that view controller. If for some reason you don't want that view controller to be the delegate/datasource for the tableview that's fine. You just create another class, descended from NSObject that is the delegate/datasource. Your view controller creates this object or it can be created in the nib.

    Remember that any top level objects in a nib have to be retained. They are created autoreleased. As a practical matter this means you need IBOutlets for them.

Share This Page