Multiple UITableViews in a Tab Bar application

Discussion in 'iOS Programming' started by jeremyapp, Jun 30, 2009.

  1. jeremyapp macrumors newbie

    Joined:
    Apr 30, 2008
    #1
    Hey,

    I'm still somewhat new to this, so please bear with me if this is a simple question.

    I have an Tab Bar application with four tabs. Each tab has its own xib file and each are linked to a single "FirstViewController" file. In the first tab, I currently have a UITableView set up and linked to a data source and delegate ("FirstTable"). This table also uses a subclass of UITableViewCell for customization. I have been able to get the data in my first tab and it works great.

    With that one working, I went to the second tab (opened up SecondView.xib, which is linked to it), and added a new UITableView. I created a "SecondTable" class and linked it to the table as the data source and delegate. I also created another subclass of UITableViewCell, specific to that table.

    The application compiles just fine, but crashes and throws "_objc_error" when I try to switch to the second tab containing the second table.

    Is there something obvious that I'm doing wrong, or have I not provided enough information? I'd provide some code, but I'm not sure what would be relevant in this case. Please let me know. Thanks!
     
  2. CorporateFelon macrumors regular

    CorporateFelon

    Joined:
    Oct 26, 2007
    Location:
    Boston, MA
    #2
    What does the console say after the crash?

    Run -> Console
     
  3. jeremyapp thread starter macrumors newbie

    Joined:
    Apr 30, 2008
    #3
    objc[640]: FREED(id): message numberOfSectionsInTableView: sent to freed object=0xd5edf0

    ...I can find that method called in my UITableViewController subclasses:

    Code:
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 3;
    }
    
    Is there something I need to retain somewhere?
     
  4. jeremyapp thread starter macrumors newbie

    Joined:
    Apr 30, 2008
    #4
    Update:

    It looks like the problem is in the
    Code:
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    call in the UITableViewController subclass for my second UITableView. After some debugging, I've found that this subclass, called "Contact" is being released for some reason. When I comment out its [super dealloc] method, it runs. Of course this isn't going to fly in the real world, but hopefully that's another clue.
     

Share This Page