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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:45:30+00:00 2026-06-05T20:45:30+00:00

Ok, so here’s the situation. I’m making a program where you can save and

  • 0

Ok, so here’s the situation. I’m making a program where you can save and load documents that contain text and images (some pretty large images). For the backend, I’m using CoreData with a UIManagedDocument and my own subclass of (let’s call this NotificationDocument) of NSManagedDocument.

Right now each NotificationDocument has two attributes representing which save slot’s its saved in and what it’s saved name is. I have a TableView which is displaying a list of my documents and which save slot they are in (ex: “Save Slot 1: Cleaning Template”).

However, it takes FOREVER for me to populate this tableview. What I am doing is in viewDidLoad is:

NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"NotificationDocument"];
NSArray *notifications = [self.database.managedObjectContext executeFetchRequest:fetchRequest error:nil];

It seems logical to suspect that my program is running so slow because I am retrieving all of the notificationDocuments in their entirety and moving them into memory. Is there a better (faster) way to do this, given that I really don’t need all the notificationDocuments, I only need their save slot and save name attributes. What would be the best way to accomplish this?

I have thought about also storing in CoreData a map entity mapping save slots to the names saved in them. However, if there was a good way to do this without saving an entirely separate entity, that would be preferable. 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-06-05T20:45:32+00:00Added an answer on June 5, 2026 at 8:45 pm

    You should be using an NSFetchedResultsController to populate your UITableView dynamically. That way, it will make the Core Data calls dynamically as new cells are requested rather than your current method, which loads all the data at once even though most of it is not needed upon loading the view.

    Here is roughly the code you should have to set up the data (fetchedResultsController should be a property of the view controller it is in)

        NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"NotificationDocument"];
        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"attribute" ascending:NO];
        fetchRequest.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
    
    
        fetchedResultsController = [[NSFetchedResultsController alloc]
                                    initWithFetchRequest:fetchRequest
                                    managedObjectContext:self.database.managedObjectContext
                                    sectionNameKeyPath:nil
                                    cacheName:@"ListCache"];
        fetchedResultsController.delegate = self;
        NSError *error = nil;
        [fetchedResultsController performFetch:&error];
    

    And here is the line to grab the correct document in cellForRowAtIndexPath (obviously might not be the correct object class)

    NotificationDocument *currentDocument = [fetchedResultsController objectAtIndexPath:indexPath];
    

    Do it this way and you’ll notice a huge speed improvement.

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

Sidebar

Related Questions

Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is a sample of text that I’m working with: Word1 Word2 ... Word4
Here is my code that I have which is pretty simple and to the
Here's the deal: I'm in the process of planning a mid-sized business application that
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
Here is the problem that I am trying to solve. I have two folders

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.