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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:54:00+00:00 2026-06-15T12:54:00+00:00

Sorry if this has been discussed already, I couldn’t find what I was after..

  • 0

Sorry if this has been discussed already, I couldn’t find what I was after..

I have a .plist file which has 2 arrays in it, which are split exactly how I would like my sections split in my table view.

I have no problem getting an array into a table view, but I cant get my head around how to tell the app that I want one array in the first section and the second array in the second section.

My code at the moment to get an array into a table is this (and it works fine):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //Create string with reference to the prototype cell created in storyboard
    static NSString *CellIdentifier = @"PlayerNameCell";

    //Create table view cell using the correct cell type
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier      forIndexPath:indexPath];

    //Create a dictionary containing the player names
    NSDictionary *players = (NSDictionary*) [[self Squad] objectAtIndex:[indexPath row]];

    //Set the cell text to the player name
    [[cell textLabel] setText:(NSString*)[players valueForKey:@"PlayerFullName"]];

    //Set the cell detail text to the squad number
    [[cell detailTextLabel] setText:(NSString*)[players valueForKey:@"PlayerSquadNumber"]];

    return cell;
}

But now I have another table view where I’ll need 2 sections, each reading from different arrays.

Any help would be greatly appreciated.

Many thanks

  • 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-15T12:54:00+00:00Added an answer on June 15, 2026 at 12:54 pm

    Just do the following:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView
    {
        return 2;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *cellIdentifier = @"PlayerNameCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
        if( cell == nil ){
            UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        }
    
        if( indexPath.section == 0 ){
            NSDictionary *players = (NSDictionary*) [self.array1 objectAtIndex:indexPath.row];
            cell.textLabel.text = (NSString*)[players valueForKey:@"PlayerFullName"];
            cell.detailTextLabel.text = (NSString*)[players valueForKey:@"PlayerSquadNumber"];
        } else {
            NSDictionary *players = (NSDictionary*) [self.array2 objectAtIndex:indexPath.row];
            cell.textLabel.text = (NSString*)[players valueForKey:@"PlayerFullName"];
            cell.detailTextLabel.text = (NSString*)[players valueForKey:@"PlayerSquadNumber"];
        }
    
        return cell;
    }
    

    Set the number of sections to 2. For each section get the different values with [self.array2 objectAtIndex:indexPath.row].

    I don’t know how you are saving the plist into 2 arrays, but if you need help with that let me know.

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

Sidebar

Related Questions

all. Sorry if this has been asked and answered already, I couldn't find this
Sorry if this has been asked before, but I couldn't find a good example
Sorry if this has already been answered but I could not find it here.
Sorry if this has already been answered, but I can't find it if so.
Sorry if this has been asked already, I've did a google search and couldn't
Sorry if this has been asked before, I did check but couldn't find anything...
im sorry if this has already been covered, i have had a look but
Sorry if this has been asked before, but I couldn't find a solution to
Sorry if this has been discussed somewhere else on stackoverflow (I could not find
Sorry if this has been asked before, I searched but couldn't find anything. I'm

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.