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

  • Home
  • SEARCH
  • 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 7937513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:32:28+00:00 2026-06-03T22:32:28+00:00

I have UITableView . in tableView:cellForRow:atIndexPath: method (when data populates to cells) I’ve implemented

  • 0

I have UITableView. in tableView:cellForRow:atIndexPath: method (when data populates to cells) I’ve implemented some kind of lazy loading. If there’s no object for key(key==row number) in rowData NSDictionary program launches requestDataForRow: method in background. so the data in cells gets populated a bit after the cell becomes visible.
Here’s the code:

static int requestCounter=0;

-(void)requestDataForRow:(NSNumber *)rowIndex
{
    requestCounter++;
    //NSLog(@"requestDataForRow: %i", [rowIndex intValue]);
    PipeListHeavyCellData *cellData=[Database pipeListHeavyCellDataWithJobID:self.jobID andDatabaseIndex:rowIndex];
    [rowData setObject:cellData forKey:[NSString stringWithFormat:@"%i", [rowIndex intValue]]];
    requestCounter--;

    NSLog(@"cellData.number: %@", cellData.number);

    if (requestCounter==0)
    {
        //NSLog(@"reloading pipe table view...");
        [self.pipeTableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
    };
}

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    [[NSBundle mainBundle] loadNibNamed:@"PipesForJobCell" owner:self options:nil];
    cell = pipeCell;
    self.pipeCell = nil;


    PipeListHeavyCellData *cellData=[[PipeListHeavyCellData alloc] init];

    if ([rowData objectForKey:[NSString stringWithFormat:@"%i", indexPath.row]]==nil)
    {
        //NSLog(@"        nil data for row: %i", indexPath.row);
        [self performSelectorInBackground:@selector(requestDataForRow:) withObject:[NSNumber numberWithInt:indexPath.row]];
    }
    else
    {
        //NSLog(@"        has data for row: %i", indexPath.row);
        PipeListHeavyCellData *heavyData=[[PipeListHeavyCellData alloc] init];
        heavyData=(PipeListHeavyCellData *)[rowData objectForKey:[NSString stringWithFormat:@"%i", indexPath.row]];
        cellData._id=[heavyData._id copy];
        cellData.number=[heavyData.number copy];
        cellData.status=[heavyData.status copy];
};

This code works, everything is OK, BUT my table has 2000 rows and If users scrolls from cell with index 10 to cell with index 2000 very quickly. He must wait for a long time until all pulling data requests will complete (for rows 11, 12, 13, …, 2000) cause that rows became visible while user was scrolling table view so the method requestDataForRow was called for them.

How can I optimize those things?

  • 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-03T22:32:29+00:00Added an answer on June 3, 2026 at 10:32 pm

    I had to do something similar. You’ll need to create a a queue that processes the most recently added items first.

    For example, the user opens the table and 10 requests are queued up. You dequeue the first object and start fetching the data for the first row. However, the user then scrolls down to rows 31-40. You’ll then have to insert those rows before the first 10 in your queue because they are now higher priority. The key is that you don’t immediately start 10 requests at once, but process them in order. That way, when the user scrolls, you only “waste” one request – the last request that was made.

    An easy way to actually implement this is to use [tableView indexPathsForVisibleRows].

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

Sidebar

Related Questions

I have a TableView loading a custom cell and loading the data from a
I have a UITableView which is populated with some parsed JSON twitter data. The
I have a set of data inside a dictionary and inside - (UITableViewCell *)tableView:(UITableView
I have the following method that should populate the cells of my UITableView with
The following method loads data from an array into custom cells of UITableView. The
I have the following: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row==0) { static
i have this that works: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath Item *objItem =
I have the following Objective-c Function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger
I have a UITableView in an iOS5.1 app where I set self.tableView.allowsMultipleSelection=YES; The Apple
I have a label on a UITableView. When clicked it will refresh my tableview

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.