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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:24:01+00:00 2026-06-02T03:24:01+00:00

From apple doc Modifying the Fetch Request I see that is possible to change

  • 0

From apple doc Modifying the Fetch Request I see that is possible to change the NSFetchRequest for NSFetchedResultsController. Steps are easy to set up.

After invoking performFetch: I think there is the need to call reloadData on the the table view. How to perform such call?

Reading some stackoverflow topics, I’ve seen that calling that method should work in most cases. But is there a right way to do it?

In How to switch UITableView’s NSFetchedResultsController (or its predicate) programmatically?, TechZen wrote that:

Just make sure to send the tableview itself a beginUpdates before you
swap controllers and then an endUpdates when you are done. This
prevents the table from asking for data in the narrow window when the
FRC are being swapped out. Then call reloadData.

Could you explain exactly what does it mean?

  • 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-02T03:24:04+00:00Added an answer on June 2, 2026 at 3:24 am

    Assuming that the logic to generate the correct fetch (some kind of conditional statement) is in the getter of your NSFetchedResultsController instance. Then it is really easy

    self.fetchedResultsController = nil; // this destroys the old one
    [self.tableview reloadData]; 
    // when the table view is reloaded the fetchedResultsController will be lazily recreated
    

    Edit: adding complete code sample of something I’ve done. Basically I have a NSDictionary entityDescription that hold values to customize the creation of a NSFetchedResultsController. If I want to change the fetchRequest I change my entityDescription variable to indicate the new values and override the setter to reset the fetchedResultsController and reload the table. It gives you the basic idea.

    - (NSFetchedResultsController *)fetchedResultsController 
    {
        if (__fetchedResultsController != nil) {
            return __fetchedResultsController;
        }
        if (self.entityDescription == nil) {
            return nil;
        }
        // Set up the fetched results controller.
        // Create the fetch request for the entity.
        NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:[self.entityDescription objectForKey:kEntityName]];
    
        // Set the batch size to a suitable number.
        [fetchRequest setFetchBatchSize:20];
    
        // Edit the sort key as appropriate.
        if ([[self.entityDescription objectForKey:kEntitySortField] isEqualToString:@"null"] == NO) {
            NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:[self.entityDescription objectForKey:kEntitySortField] ascending:YES];
            NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];
            [fetchRequest setSortDescriptors:sortDescriptors];
        }
    
        // Edit the section name key path and cache name if appropriate.
        // nil for section name key path means "no sections".
        NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest 
                                                                                                    managedObjectContext:self.moc sectionNameKeyPath:nil cacheName:nil];
        aFetchedResultsController.delegate = self;
        self.fetchedResultsController = aFetchedResultsController;
    
        NSError *error = nil;
        if (![self.fetchedResultsController performFetch:&error]) {
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
            abort();
        }
    
        return __fetchedResultsController;
    }
    
    - (void)setEntityDescription:(NSDictionary *)entityDescription
    {
        _entityDescription = entityDescription;
        self.fetchedResultsController = nil;
        [self.tableView reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Strange situation - examples from apple works, but after i change them a bit,
I'm trying to grab some JSON from Apple's iTunes JSON service. The request is
reading the doc from apple I need to create an ad-hoc distribution app, and
I'm trying to change color of an image in a background thread. Apple doc
Before/After call the block, the retaincount is always 1. From apple block doc we
In the BubbleLevel example from apple they implement an +initialize method. They say: +initialize
This is unmodified code from Apple's iPhone 'Utility Aplication' template: - (void)applicationDidFinishLaunching:(UIApplication *)application {
I went through the example from apple MoviePlayer on iPhone Im trying to overlay
I have downloaded sample code from Apple Center.I also have gone through following question:
I just installed the latest SDK from Apple so I can start learning iPhone

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.