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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:33:59+00:00 2026-05-28T23:33:59+00:00

I have the following code in my search method that updates the tableview. for

  • 0

I have the following code in my search method that updates the tableview.

for (int x = 0; x < [array count]; x++) {
//network stuff here
self.searchedReservations = [aSearchObjectType objectsFromServerDictionaries:aResultsArray];
[self.aTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
}

Each object in the array represent a section in my table, for most cases the count will be 4, so 4 sections.

Right now, the code is loading the same data for all sections in the table’s cells. Instead of the unique data for each section of the table.

Here is the code that loads the cells. I’m missing some logic that maps the data to the right section of the table.

MyClass *object = [self.searchedReservations objectAtIndex:iIndexPath.row];
cell.textLabel.text = object.customerFullName;
  • 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-28T23:34:00+00:00Added an answer on May 28, 2026 at 11:34 pm

    I assume you have the code below in your ‘cellForRowAtIndexPath’ method:

    MyClass *object = [self.searchedReservations objectAtIndex:iIndexPath.row];
    cell.textLabel.text = object.customerFullName;
    

    Tables are organised into sections, then within each section there are rows. The rows start at zero again for each section.

    If you are on section 0, loading cell 0 this code above is not taking the section number into account, only the row number – so it is loading:

    [self.searchedReservations objectAtIndex:0] 
    

    to populate the cell.

    When you are on section 1, loading cell 0 in section one, you are retrieving exactly the same value because you are just using the row number. ie. you’re still loading

    [self.searchedReservations objectAtIndex:0]
    

    You may think that you are changing the value of the ‘searchedReservations’ object between the loading of each section (this is what it looks like you’re trying to do in the loop above) but I’m not sure that this is working (as the code the populate searchedReservation doesn’t seem to do anything different in each loop counter). Also the first time the table loads it will run through all of the rows in all of the sections anyway.

    I think you need to either use the indexPath.section field as well as the indexPath.row field at the time you are populating the cell to ensure you are setting the appropriate row in the appropriate section.

    Also use the debugger to see whats going on in your cellForRowAtIndexPath method and in your loop and make sure that you are getting/using a different ‘searchedReservations’ object for each incrementation of the loop and that this matches the ‘searchedReservations’ object in the cellForRowAtIndexPath method.

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

Sidebar

Related Questions

I have the following code in my .Zshrc function google; { $VIEW http://www.google.com/search?q='url-encode ${(j:
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have the following method that retrieves all the appointments between 2 dates: def
I have the following code (thanks to input from 'jon Z' and 'manojlds') that
I have rewritten the Binary Search Tree code found in the following links to
I have the following snippet of code (as an example) that looks up a
I am implementing a Binary Search tree in C++ I have the following code
I have the following lines of code: if(std::binary_search(face_verts.begin(), face_verts.end(), left_right_vert[0]) && std::binary_search(face_verts.begin(), face_verts.end(), left_right_vert[1]))
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section

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.