Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 997145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:59:11+00:00 2026-05-16T06:59:11+00:00

I need an example or explanations of how to populate 2 table views which

  • 0

I need an example or explanations of how to populate 2 table views which are on the same view. I need to understand the “cellForRowAtIndexPath” method, could someone provide me an example on how should the code be?

I mean how to identify which goes which table view?

Thanks

Below is my cellForRowAtIndexPath method:

 // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

// Configure the cell...
// Set up the cell
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
    if (tableView == radios_tv) { //radio_tv is an IBOutleet UITableView
        sqlClass *aRadio = (sqlClass *)[appDelegate.array_radios objectAtIndex:indexPath.row];
        [cell setText:aRadio.r_name];
        return cell;
    }
    if (tableView == presets_tv) { //preset_tv is an IBOutlet UITableView


    }

}

and hey vikingsegundo, now I need to delete a cell which is on my TableViewController class, how do I do this? I explain, here is my code:

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath {

    if(editingStyle == UITableViewCellEditingStyleDelete) {

        //Get the object to delete from the array.
        Coffee *coffeeObj = [appDelegate.coffeeArray objectAtIndex:indexPath.row];
        [appDelegate removeCoffee:coffeeObj];

        //Delete the object from the table.
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
}

Since we put different controllers, how should we proceed for this line? Should I put the tableViewController instead of the “self”?

//Delete the object from the table.
            [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:59:11+00:00Added an answer on May 16, 2026 at 6:59 am

    IMO the cleanest solution would be to have one controller for each tableview.

    radios_tv would call it own delegate’s method, while presets_tv calls it own.

    edit

    if you use one controller for n tableview, you will have to use if-statemenst in many places,
    in

    • – numberOfSectionsInTableView:
    • – tableView:numberOfRowsInSection:
    • – tableView:titleForHeaderInSection:
    • …

    basically in all UITableViewDatasource-Protocol methods that you will need to implement.

    So if you need to change something, you have to change it in many places.

    If you use one controller class for one tableview, you won’t have to check at all.

    1. write a controller class for every tableview, make it conforming to the UITableViewDatasource protocol
      • implement the protocol methods you will need. at least
        • – numberOfSectionsInTableView:,
        • – tableView:numberOfRowsInSection:,
        • – tableView:cellForRowAtIndexPath:
    2. call -setDataSource:for every tableview to an object of the right controller class

    I think, it was shown in one of the WWDC 2010 videos. I am not sure, but I guess it was Session 116 – Model-View-Controller for iPhone OS.

    edit

    I wrote an example code: http://github.com/vikingosegundo/my-programming-examples

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I grabbed an example off of this SO question , and built my own
i heard that these(say for example Groovy) languages have the capability of changing the
Imagine an auction (ebay auction, for example). You create an auction, set the start
I am currently doing some performance tests on Hibernate / Hibernate.Search with Lucene in
I'm working with CakePHP 1.3.7 and I'm trying to do the following: On a
I have a project I'm working on called Natalie. What it does, (twitter.com is
I am trying to implement a feature where if there are 50 links on
I have found many calculations here and some php examples and most are just
Hi all this is my post on stackoverflow. I am normally a lurker and
I have a series of tables related to Polls, they store information regarding them,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.