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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:57:15+00:00 2026-05-28T00:57:15+00:00

I am using the TableViewUpdates example from WWDC #2010. Basically Apple creates collapsable and

  • 0

I am using the TableViewUpdates example from WWDC #2010. Basically Apple creates collapsable and expandable TableViews by clicking on the section header. The data for the TableView gets created in viewWillAppear like so:

- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated]; 

    /*
     Check whether the section info array has been created, and if so whether the section count still matches the current section count. In general, you need to keep the section info synchronized with the rows and section. If you support editing in the table view, you need to appropriately update the section info during editing operations.
     */
    if ((self.sectionInfoArray == nil) || ([self.sectionInfoArray count] != [self numberOfSectionsInTableView:self.tableView])) {

        // For each play, set up a corresponding SectionInfo object to contain the default height for each row.
        NSMutableArray *infoArray = [[NSMutableArray alloc] init];

        for (Play *play in self.plays) {

            SectionInfo *sectionInfo = [[SectionInfo alloc] init];          
            sectionInfo.play = play;
            sectionInfo.open = NO;

            NSNumber *defaultRowHeight = [NSNumber numberWithInteger:DEFAULT_ROW_HEIGHT];
            NSInteger countOfQuotations = [[sectionInfo.play quotations] count];
            for (NSInteger i = 0; i < countOfQuotations; i++) {
                [sectionInfo insertObject:defaultRowHeight inRowHeightsAtIndex:i];
            }

            [infoArray addObject:sectionInfo];
            [sectionInfo release];
        }

        self.sectionInfoArray = infoArray;
        [infoArray release];
    }

}

I’ve noticed for my case, where I have a lot of data, this is an expensive operation. I’d like to cache the data. The data gets created each time since it’s in viewWillAppear. Because I’m using a UINavigationController to push this view onto the stack, if I put it into viewDidLoad, when I move away from this view and go back to home, I have to recreate the view again, viewDidLoad will run again, and it’ll be slow again.

I haven’t cached data before and was wondering what a good way to do it would be? Right now all of the data for the row headers and rows are in a database. So when this view gets pushed onto the stack, I grab the data, and create the table. I didn’t know what a good mechanism would be to create the table and somehow cache the view or something to make it load faster on subsequent pushes of the viewController. Thanks.

  • 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-28T00:57:15+00:00Added an answer on May 28, 2026 at 12:57 am

    The code you are showing is constructing the data source for the table view, and is not part of the view itself, per se. Wouldn’t it meet your needs to execute this code in the view controller initializer and/or whenever your data source requires an update?

    You can draw the parallel with NSFetchedResultsController and its delegate methods. These are executed apart form the view handling methods, with the fetched results controller being an ivar or (very often) a property of your view controller. Then, for example, once a fetched results controller has done its fetch, it can manage changes on a case-by-case basis, coordinated with the table view and its controller, or you can purposely refetch entirely. The view can appear and disappear completely independent of the data source maintenace.

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

Sidebar

Related Questions

Using Rails 3.2.0 with haml, sass and coffeescript: Basically I am trying to disable
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using SQL Server 2005 Leave Table ID StartDate EndDate 001 02/03/2010 02/03/2010 002 02/03/2010
Using Java, how can I extract all the links from a given web page?
Using Visual C++ 2008. First time, I'm experimenting in crossing over from C# and
Using JAXB in Java it is easy to generate from a xml schema file
Using delphi 2010, i am wondering if there someway to escape the following string
Using mercurial, I've run into an odd problem where a line from one committer
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and

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.