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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:22:33+00:00 2026-05-23T19:22:33+00:00

I was wondering about good and memory efficient ways to reload all the changes

  • 0

I was wondering about good and memory efficient ways to reload all the changes made to an UITableView. Imagine the native Note Apps of Apple which refreshes the UITableView if you’ve changed the date/title of a note.

When I animate the index into view which shows you the contents, I make sure to reload my index data like so

[indexTable reloadData];

Now the only problem is that not every cell will be refreshed if it was used before, because I had this in my function which loads the cells:

//if (cell == nil) { // assign a label to them, e.g. the title of a note

    //} else {
    //   label = (UILabel *) [cell viewWithTag:1];
    //}

See below for the entire code. I am now actually wondering that the label = (UILabel *) [cell viewWithTag:1]; bit does? All I know is that it doesn’t refresh my data if the user has entered a new note title for instance (despite me calling indexTable reload!).

Will I run into serious problems by leaving it out as I do in the following code?

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

    static NSString *CellIdentifier = @"Cell";    
    UILabel *label;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    //NSLog(@"checking if cell is nil");

    //if (cell == nil) {

        NSLog(@"cell=nil");

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        CGRect frame = CGRectMake(10, 0, 200, 30);
        label = [[UILabel alloc] initWithFrame:frame];
    label.lineBreakMode = UILineBreakModeTailTruncation;
        label.tag = 1;
    label.text = [[indexContent objectAtIndex:indexPath.row] itemTitle];

        [cell.contentView addSubview:label];
        [label release];

    //} else {
    //   label = (UILabel *) [cell viewWithTag:1];
    //}

    return cell;
}

Any explanations would be very much appreciated!

  • 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-23T19:22:33+00:00Added an answer on May 23, 2026 at 7:22 pm

    You should check for the result of
    [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; to be nil, although not doing so, won’t make your app crashing, you will init/alloc a new cell each time this method is called, and it’s better to try to reuse a cell (why trying to resue the cell, if you alloc/init a new one each time ?).
    label = (UILabel *) [cell viewWithTag:1]; doesn’t make any refresh for sure, it just retrieve a UILabel, which is a subview of the cell, given a tag. In the if part, you alloc/init a new cell because it is required and configure its frame, lineBreakMode, and tag properties and add it to the cell.

    So in order for your content to refresh (using [tableView reloadData];), extract the UILabel content setting part outside the if/else sequence, and cut off the else part :

    if(cell == nil) {
        //init/alloc and configure a new cell
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:CellIdentifier] autorelease];
        CGRect frame = CGRectMake(10, 0, 200, 30);
        label = [[UILabel alloc] initWithFrame:frame];
        label.lineBreakMode = UILineBreakModeTailTruncation;
        label.tag = 1;
        [cell.contentView addSubview:label];
        [label release];
    
    }
    // you either retrieved the cell, or just created it
    // retrieve the label and update the content
    label = (UILabel *) [cell viewWithTag:1];
    label.text = [[indexContent objectAtIndex:indexPath.row] itemTitle];
    return cell;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering what good ways there would be make assertions about synchronization or something
I'm wondering how you would go about designing a good permgen space string in
im wondering about how to set up a clever way to have all my
I was wondering if anyone knows about good tutorials or articles describing methods of
I was recently wondering about a good library for XML manipulation in Java: A
I'm wondering about a good method to enumerate in Java. I've wondered this for
I was wondering if anyone knows about a good article which describes dividing workload
Just wondering about the performance impact of copying very large php variables. For example
I'm wondering about instances when it makes sent to use #define and #if statements.
I'm wondering about MP3 decoding/encoding, and I was hoping to pull this off in

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.