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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:47:05+00:00 2026-06-03T14:47:05+00:00

Edit * So it seems I’ve using this for the wrong purpose and the

  • 0
  • Edit * So it seems I’ve using this for the wrong purpose and the delegate will never be called upon the initial fetch. I wanted to use this to batch process the fetch, since even though the actual fetching of data is fast, the post-processing is not. I just need to off load into a background process instead * Edit *

I create a NSFetchedResultsController in the ViewDidLoad method of a UIViewController and set the delegate to self:

self.resultsController = [[[NSFetchedResultsController alloc] initWithFetchRequest:self.fetchRequest managedObjectContext:[AppDelegate singleton].managedObjectContext sectionNameKeyPath:nil cacheName:nil] autorelease];
self.resultsController.delegate = self;

Then when the ViewController is tapped, I perform the fetch if needed:

int indexPathCount = self.indexPaths.count;
int objectCount = self.resultsController.fetchedObjects.count;
if (indexPathCount && objectCount)
{
     [self.tableView beginUpdates];
     [self.tableView insertRowsAtIndexPaths:self.indexPaths withRowAnimation:UITableViewRowAnimationFade];
     [self.tableView endUpdates];
}
else
{
     NSError* error;
     BOOL success = [self.resultsController performFetch:&error];
     if (!success)
     {
          UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"ERROR" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
          [alert show];
     }
}

The above code will not fetch any objects and the delegate methods are never called. If I comment out the line of code above where I assign the UIViewController as the delegate, then during the second run through of the tapped code, the objectCount will contain a the correct value.

  • EDIT * The above code will now actually fetch the objects. On a second run through of the code, the objectCount is now as expected, but still no delegate methods being called. Right now my assumption is that I’m doing something bad with the memory management, but all my retain counts seem to be spot on. * EDIT*

Here is the implementation of the delegate methods, but I’ve checked the them for correctness a dozen times over:

- (void)controllerWillChangeContent:(NSFetchedResultsController*)controller
{
     [self.tableView beginUpdates];
}

- (void)controller:(NSFetchedResultsController*)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath*)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath*)newIndexPath
{
     switch(type)
     {
          case NSFetchedResultsChangeInsert:
          {
               NSIndexPath* tableIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row inSection:self.section];
               [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:tableIndexPath] withRowAnimation:UITableViewRowAnimationFade];
               [self.indexPaths addObject:tableIndexPath];
          } break;
     }
}

- (void)controllerDidChangeContent:(NSFetchedResultsController*)controller
{
     [self.tableView endUpdates];
}

Any ideas on why the NSFetchedResultsController is not working when supplied a delegate?

  • 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-03T14:47:07+00:00Added an answer on June 3, 2026 at 2:47 pm

    Not enough information. Well, not the right information. Since you didn’t post, I’ll have to assume…

    First, what does your fetch request look like? Does it properly specify the objects to fetch? Does it have a sort descriptor (a requirement for a FRC fetch request)?

    Normally, you kick off the request when the view controller loads… the manual calling of inserting the data like your code show is, well, let just say unconventional,

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

Sidebar

Related Questions

This seems like such a simple question. I have several Edit boxes on my
Edit: Seems numerous people think this is a dumb idea, so I would appreciate
Edit: Seems like Facebook finally fixed this bug! Could you help me understand why
EDIT: It seems to be something with having the two queues in the same
[edit] So it seems my code works fine, another piece of code + tiredness
Which algorithms or data structures are used in auto-suggest features? It seems that edit-distance
It seems it allows you to edit the content of an element, but what
Markdown seems to be easier to write and edit than HTML. All HTML editors
[EDIT] Based on feedback yes, VS2010 seems to support SL4 Library TDD despite a
Whenever I edit files on emacs, it seems a temporary file is created with

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.