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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:56:17+00:00 2026-06-13T11:56:17+00:00

I’m having a big performance issue on my tableviewcontroller. The scroll is very slow.

  • 0

I’m having a big performance issue on my tableviewcontroller. The scroll is very slow. I’ve made a NSLOG on the didSelectRowAtIndexPath method, and I realized that this is called on every scroll I do. It’s supposed to be like that?

I’ve a search on this table, and I’ve some logic because the data depends of the json response. You can check this method here:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        //NSLog(@" scroll");
        // Configure the cell...
    static NSString *CellIdentifier = @"contactCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    UILabel *nameLabel = (UILabel *)[cell viewWithTag:1];
    UILabel *workPlaceLabel = (UILabel *)[cell viewWithTag:2];

    if(searching)
    {
            //NSLog(@" copyListOfItems: %@",copyListOfItems);
        NSString*lastName=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"]objectForKey:@"lastname"];
        if(lastName==nil)
        {
            lastName=@" ";
        }
        NSString*firstName=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"]objectForKey:@"firstname"];
        if(firstName==nil)
        {
            NSArray*phonesArray=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"]objectForKey:@"phone"];
            NSLog(@"NUMERO TELEFONE %d",[phonesArray count]);

            if([phonesArray count]>0)
            {
                NSString*phoneNumber=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Phone"];
                nameLabel.text=phoneNumber;
            }else{
                nameLabel.text=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Current"];
                workPlaceLabel.text=@"";
            }

        }else{
            NSString *stringName= [NSString stringWithFormat:@"%@ %@", firstName, lastName];
            nameLabel.text=stringName;
            workPlaceLabel.text=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Current"];
        }
    }
    else {
            //NSLog(@" _contactsArray: %@",_contactsArray);
        NSString*lastName=[[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Lastname"];
        if(lastName==nil)
        {
            lastName=@" ";
        }
        NSString*firstName=[[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Firstname"];
        if(firstName==nil)
        {
            NSArray*phonesArray=[[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Phone"];
                //NSLog(@"NUMERO TELEFONE %d",[phonesArray count]);

            if([phonesArray count]>0)
            {
                NSString*phoneNumber=[[[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"phone"] objectAtIndex:0]objectForKey:@"phonenumber"];
                nameLabel.text=phoneNumber;
            }else{
                nameLabel.text=[[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Current"];
                workPlaceLabel.text=@"";
            }
        }else{
            NSString *stringName= [NSString stringWithFormat:@"%@ %@", firstName, lastName];
            nameLabel.text=stringName;
           if([[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Current"])
            {
            workPlaceLabel.text=[[[_contactsArray objectAtIndex:indexPath.row]objectForKey:@"Contact"] objectForKey:@"Current"];

        }
        }
    }
        // Configure the cell...
    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-13T11:56:18+00:00Added an answer on June 13, 2026 at 11:56 am

    There are a lot of needless calls in this that could be removed from your code. All those calls to get a contact that are repeated are taking time to perform when you could make them once. Like in your first branch of the if statement, you have calls like these:

    NSString*lastName=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"]objectForKey:@"lastname"];
    NSString*firstName=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"]objectForKey:@"firstname"];
    NSArray*phonesArray=[[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"]objectForKey:@"phone"];
    

    You could compact these calls by doing something like this:

    id contact = [[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"];
    NSString *lastName=[contact objectForKey:@"lastname"];
    NSString *firstName=[contact objectForKey:@"firstname"];
    NSArray *phonesArray=[contact objectForKey:@"phone"];
    

    Ideally though, you would have a class of your own that has those items as properties so you could do something like this:

    Contact *contact = (Contact *)[[copyListOfItems objectAtIndex:indexPath.row]objectForKey:@"Contact"];
    NSString *lastName = contact.lastName;
    NSString *firstName = contact.firstName;
    NSArray *phonesArray = contact.phone;
    

    Edit: How to do asynchronous image loading

    Here’s how I’ve done asynchronous loading of an image with a placeholder image in the past. The cell I was using was a custom class I wrote, but it should give you an idea of how to do it.

    // Setup the image view
    UIImageView* imageView = cell.imageView;
    imageView.image = [UIImage imageNamed:@"Loading.png"];
    
    // Load the image asynchronously
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(queue, ^{
        // Here you will want to make a call to your web server to get the image
        // and store it in a UIImage named image
        UIImage *image = // your code to get the image from the server
    
        // Only update if the cell is still on the screen
        if ([[tableView indexPathsForVisibleRows] containsObject:indexPath]) {
            // Have to update UI elements on the main thread
            dispatch_sync(dispatch_get_main_queue(), ^{
                [[cell imageView] setImage:image];
                [cell setNeedsLayout];
            });
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I have an array which has BIG numbers and small numbers in it. I

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.