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 8854467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:53:14+00:00 2026-06-14T13:53:14+00:00

I have two tables (Cell Identifier: Call and Cell Identifier: Cell2). I’m passing two

  • 0

I have two tables (Cell Identifier: Call and Cell Identifier: Cell2). I’m passing two arrays of Objects (one for each table) however when I go to do this in my tableView my 2nd table is bringing up the same data as my first table and not the data from the 2nd array. My arrays are set globally as NSMutableArray in my .h file. This is where I think the problem is within the code:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

   // NSString *currDate = [[array objectAtIndex:indexPath.row] objectForKey:@"Current Date"]; //added
   //  NSString *someOtherKey = [[array objectAtIndex:indexPath.row] objectForKey:@"Some other key"]; //added


    cell.textLabel.text = [array objectAtIndex:indexPath.row];
    label1.text = [arrayDate1 objectAtIndex:indexPath.row];
    label2.text = [arrayDate2 objectAtIndex:indexPath.row];

   // cell.textLabel.text = [NSString stringWithFormat:@"%@  %@", currDate, someOtherKey]; //added

    return cell;



    //This will Load the second table (myTableView2)
    static NSString *CellIdentifier2 = @"Cell2";


    UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];

    if(!cell2)
    {
        cell2 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
    }

    // NSString *currDate = [[array objectAtIndex:indexPath.row] objectForKey:@"Current Date"]; //added
    //  NSString *someOtherKey = [[array objectAtIndex:indexPath.row] objectForKey:@"Some other key"]; //added


    cell2.textLabel.text = [array2 objectAtIndex:indexPath.row];


    return cell2;
}
  • 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-06-14T13:53:15+00:00Added an answer on June 14, 2026 at 1:53 pm

    It is indeed a problem in this function:

    The code as written, will simply run until it gets to the first return cell; line and never run the code after that, therefore always returning an instance of a Cell cell.

    In order to use two tables like this, you need to be able to tell them apart. Usually, you store both of them in a declared property. For the rest of this answer, I’ll assume that you are doing that and that they are called table1 and table2.

    Change you code to look like this:

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if ([tableView isEqual:self.table1]) {
            static NSString *CellIdentifier = @"Cell";
    
    
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
            if(!cell)
            {
                cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            }
    
           // NSString *currDate = [[array objectAtIndex:indexPath.row] objectForKey:@"Current Date"]; //added
           //  NSString *someOtherKey = [[array objectAtIndex:indexPath.row] objectForKey:@"Some other key"]; //added
    
    
            cell.textLabel.text = [array objectAtIndex:indexPath.row];
            label1.text = [arrayDate1 objectAtIndex:indexPath.row];
            label2.text = [arrayDate2 objectAtIndex:indexPath.row];
    
           // cell.textLabel.text = [NSString stringWithFormat:@"%@  %@", currDate, someOtherKey]; //added
    
            return cell;
        } else if ([tableView isEqual:self.table2]) {
    
    
            //This will Load the second table (myTableView2)
            static NSString *CellIdentifier2 = @"Cell2";
    
    
            UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
    
            if(!cell2)
            {
                cell2 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
            }
    
            // NSString *currDate = [[array objectAtIndex:indexPath.row] objectForKey:@"Current Date"]; //added
            //  NSString *someOtherKey = [[array objectAtIndex:indexPath.row] objectForKey:@"Some other key"]; //added
    
    
            cell2.textLabel.text = [array2 objectAtIndex:indexPath.row];
    
    
            return cell2;
        }
    
    }
    
    // If you reach this point, we don't recognize the table and return `nil`, then the program will crash.  Handle this however you want.
    return nil;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two table cells, with dynamic content. Table cell one works fine, when
I have two table views, when user clicks one cell of the first, second
I have two tables one with ID and NAME table 1 ID | NAME
i have a table view. And im adding two buttons to each cell: -
I have a UITableView and a UITableCell subclass. Each table cell has two scrollviews
I have two XML files: data1.xml <?xml version=1.0 encoding=UTF-8?> <tables> <table> <row> <cell colname=1>A</cell>
In my iPhone app, In Table view I have Two labels in one cell..
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables user table user_id | name | 1 | peter |
I have two tables, a user table and a application table: User id username

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.