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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:24:59+00:00 2026-06-07T02:24:59+00:00

I am using UIDocument to access core data and trying to setup NSFetchedResultsController in

  • 0

I am using UIDocument to access core data and trying to setup NSFetchedResultsController in a background thread not to block main UI. It works if i use the uidocument’s managedobjectcontext but not the child. I took some of this code from one of the answers here at stack overflow but are not able to make it work with fetchedresultscontroller.

[ZH peopleDocumentusingBlock:^(UIManagedDocument *peopleDoc){
NSManagedObjectContext *context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
        context.parentContext = peopleDoc.managedObjectContext;
        [context performBlock:^{
             NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Person"];
           request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"key" ascending:YES]];
            [NSFetchedResultsController deleteCacheWithName:nil];
            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"imageurl.length>0"];
            request.predicate = predicate;

            NSError *error = nil;
            if(!self.totalNumberOfPeople) //set total number of people for this fetch used for show more records
            {
                self.totalNumberOfPeople = [context countForFetchRequest:request error:&error]; 
                NSLog(@"total number of people -> %d",self.totalNumberOfPeople);

            }

                self.fetchedResultsController = [[NSFetchedResultsController alloc]initWithFetchRequest:request managedObjectContext:context sectionNameKeyPath:nil cacheName:@"peopleCache"];
dispatch_async(dispatch_get_main_queue(), ^{
                    [self.delegate refreshPeoplelTableview];
                    NSLog(@"fetched objects -> %d",[self.fetchedResultsController.fetchedObjects count]);
                    NSLog(@"total number of people -> %d",self.totalNumberOfPeople);


                });
    }];
}];

Actually context countforfetchrequest does but not fetcheresultscontroller.

Thanks in advance!

  • 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-07T02:25:01+00:00Added an answer on June 7, 2026 at 2:25 am

    You are using a “semi-permanant” FRC (it is an instance variable of your controller), but setting it to use a “temporary” MOC, that will go away when no one is using it anymore.

    I do not follow what you are really trying to do, but I would think if you store the “temporary” MOC, it will work. Though, you then have to ask why you are doing all this in the first place.

    Insert the code between parentContext and performBlock

        context.parentContext = peopleDoc.managedObjectContext;
        // Keep the MOC with the FRC...
        self.myBackgroundFetchingMoc = context;
        [context performBlock:^{
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the iCloud Key-Value Data storage solution, so I'm not working with documents
I am using UIManagedDocument's Context to interact with my Core Data Model. However, I
I'm using a UIDocument with iCloud. I'm not using CoreData. What's the best way
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using Rails 3.2.0 with haml, sass and coffeescript: Basically I am trying to disable
To support iCloud, we're encouraged to use a UIDocument subclass. If I define a
Using Android TelephonyManager an application can obtain the state of data activity over the
I am using LINQ to retrieve data from the Database, the variable name relative

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.