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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:04:18+00:00 2026-06-09T20:04:18+00:00

I have a UITableView that was working fine until I added sections to it

  • 0

I have a UITableView that was working fine until I added sections to it – now the data from the first cell repeats throughout all the other cells. When I remove the sections line below, everything goes back to normal.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    NSInteger sections = self.objects.count;

    return sections;
}

Any ideas on what could be going on here? My data source is Core Data, by the way.

EDIT

For numberOfRows I’m returning 1.

Here’s how I’m implementing the cells:

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {

Item *p = [[[ItemStore defaultStore] allItems]
                                objectAtIndex:[indexPath row]];

    ItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemCell"];

    [cell setController:self];
    [cell setTableView:tableView];

    [[cell nameLabel] setText:[p itemName]];
    [[cell serialNumberLabel] setText:[p serialNumber]];
    [[cell valueLabel] setText:[NSString stringWithFormat:@"$%d", [p valueInDollars]]];

    [[cell thumbnailView] setImage:[p thumbnail]];


return cell;
}
  • 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-09T20:04:21+00:00Added an answer on June 9, 2026 at 8:04 pm

    You are probably using

    cell.textlabel.text = [self.objects objectAtIndex: indexPath.row];
    

    in your cellForRowAtIndexPath method.

    This would work in a table view with one section, as the row number will increase each time.
    However, if you have multiple sections, the row number is reset back to 0 for the first row in each section.
    Therefore, indexPath.row will always return 0 in the cellforRowAtIndexPath method, hence you are getting the first object each time.
    You will have to do a check for which section you are in, or even use the section number as a way of getting the correct object from the array.

    EDIT: Looking at the code you’ve posted, this is exactly what’s happening! Look into identifying which section you’re in, and filling it appropriately.

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

Sidebar

Related Questions

I have a UITableView that is being populated by core data. Now, when I
I have a UITableView that was created from data coming from a mutable array.
I have a UITableView with 3 sections that are hard coded. Everything is working
I have a UITableView that lists comments from various users. I save all of
I have a UITableView that displays single large images in each cell. The names
I have a uitableview that loads fairly large images in each cell and the
I have a UITableView that displays various nsstrings from a custom object called a
I have a UITableView that displays some data that is read in at runtime
I have a UITableView that has five sections. Just as the title describes cellForRowAtIndexPath
I have a uitableview that is populated from a sqlite query. I want to

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.