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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:07:51+00:00 2026-06-05T08:07:51+00:00

I have setup a Core Data app with the usual boilerplate code, and the

  • 0

I have setup a Core Data app with the usual boilerplate code, and the RootViewController initializes the FRC by calling this:

- (NSFetchedResultsController *)fetchedResultsController 
{
    if (__fetchedResultsController != nil) 
    {
        return __fetchedResultsController;
    }
    // configure the fetchRequest, sectionKey and cacheName
    __fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest 
                                                                    managedObjectContext: self.managedObjectContext 
                                                                      sectionNameKeyPath: sectionKey 
                                                                               cacheName: cacheName];
    return __fetchedResultsController;
}

All the sample code I’ve seen does this. However, I have a large data set and with over 15,000 entries, it takes about 5 seconds to launch the app on the iPhone 4S. This is with caching enabled (without it, it takes 11 seconds), and with indexed attributes.

So I want to be able to show a UIActivityIndicatorView which the app is waiting for this to load. I know how to generally load core data objects in the background thread and then merge them back into the main thread, but how can I initialize the FRC in the background thread so that all the objects are loaded and sectioned in the background?

I know I can load all the objects and partition them in a background thread into a custom dictionary and use that to present the data, but I would rather use the standard FRC calls and delegates.

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-05T08:07:52+00:00Added an answer on June 5, 2026 at 8:07 am

    I think I’ve figured it out… you CAN create the FRC in the background thread and do the fetch in the main thread:

    - (NSFetchedResultsController *)fetchedResultsController 
    {
        if (__fetchedResultsController != nil) 
        {
            return __fetchedResultsController;
        }
    
        // create something to pass back to the first time FRC is initialized without fetching
        __block NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
        aFetchedResultsController.delegate = self;
        [self.list_spinner startAnimating];
    
        dispatch_async(self.filterMainQueue, ^{
    
               NSFetchedResultsController *newFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest 
                                                                                                             managedObjectContext: self.managedObjectContext 
                                                                                                               sectionNameKeyPath: sectionKey 
                                                                                                                        cacheName: cacheName];
               dispatch_async(dispatch_get_main_queue(), ^{ 
                   // stop the spinner here
                   [self.list_spinner stopAnimating];
    
                   NSError *error = nil;
                   if (![newFetchedResultsController performFetch:&error]) 
                   {
                       NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
                       [SimpleListAppDelegate showCoreDataError: @"SimpleListViewController - FRC"];
                   }
                   __fetchedResultsController = nil;
                   newFetchedResultsController.delegate = self;
                   __fetchedResultsController = newFetchedResultsController;
                   [self.tableView reloadData];
               });
             });
    
        return aFetchedResultsController;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup Core Data for an iPhone app without an instance of NSFetchedResultsController.
I have Core Data setup in my app and need to fetch a bunch
I have started creating an app which uses a core data stack at the
I have an iPhone/iPad app which uses Core Data. In my DB I have
I'm using Core data in an iOS project. I have the data model setup
I have just started using core data. I want to setup a pre-populated db.
I am building an app with use of core data. My RootViewController, loaded by
I am creating Travel guide app using core data. I have 4 entities CITY
I have a core data based app I am working on, that uses an
I have core data configuration in my iPhone app, and how I'm currently passing

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.