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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:04:36+00:00 2026-05-17T23:04:36+00:00

I have a NSFetchedResultsController which displays data in a UITableView. I’m using the boiler

  • 0

I have a NSFetchedResultsController which displays data in a UITableView. I’m using the boiler plate code provided by Xcode when choosing to create a Core Data project. I added the following predicate to the NSFetchRequest the NSFetchedResultsController uses (before NSFetchedResultsController is initialized):

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"deleted == NO"];
[fetchRequest setPredicate:predicate];

Now in another location of my app, I set the deleted property like so (pseudo-code):

myManagedObject.deleted = YES
saveDataContext

When I return to the TableViewController, it still shows this “deleted” row.

When I try to reload the table view, nothing happens.

When I try to reload the fetchedResultsController using performFetch, it says:

‘FATAL ERROR: The persistent cache of section information does not match the current configuration. You have illegally mutated the NSFetchedResultsController’s fetch request, its predicate, or its sort descriptor without either disabling caching or using +deleteCacheWithName:’

If I remove the caching, in the init method, call performFetch, then call [myTable reloadData] it works.

Isn’t there a simpler way to refresh the data? Preferably one that allows you to use the caching feature of NSFetchedResultsController?

As far as I know, the only place I am modifying the fetch request, predicate, or sort descriptor is in the same method that allocs and inits the NSFetchedResultsController, so it seems that the error message that it displays is incorrect.

Update: Now that I understand the NSFetchedResultsController a bit better, I understand that it won’t remove rows for you automatically, and it’s the controller:didChangeObject:atIndexPath:forChangeType:nowIndexPath: method that is primarily responsible for deleting rows. I had this method implemented, since I used Apple’s template for my project.

However, in my case I’m not actually deleting an item, I’m just updating a property (deleted) to specify that the item should no longer exist in the list. This means that the controller:didChangeObject:atIndexPath:forChangeType:nowIndexPath: method’s change type is NSFetchedResultsChangeUpdate and not NSFetchedResultsChangeDelete. I updated the code to something such as:

  case NSFetchedResultsChangeUpdate: {
    MyObj *obj = (MyObj *)anObject;
    if (obj.deletedValue) { // NOTE: deletedValue returns the deleted property as BOOL
      [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else {
      [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
      break;
    }
  }

The problem with this is that I get the error message:

Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (1 inserted, 2 deleted). with userInfo (null)

Basically it’s complaining that the number of objects in the NSFetchedResultsController and the number of cells in the table aren’t synced.

Hopefully this makes it clearer:

// DB Items (Name, Deleted):
[Foo, NO]
[Bar, NO]
[Baz, NO]

// mark one as deleted
Objects[1].deletedValue = YES;

// DB items now look like so:
[Foo, NO]
[Bar, YES]
[Baz, NO]

Even though NSFetchedResultsController’s NSFetchRequest’s NSPredicate is set to deleted == NO, the NSFetchedResultsController still sees 3 items instead of 2.

How can I solve this issue? Would I need to refresh the NSFetchedReultsController somehow? What else could be the problem?

  • 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-05-17T23:04:36+00:00Added an answer on May 17, 2026 at 11:04 pm

    The problem was that I didn’t realize that deleted is a reserved word in this case. I had to rename the field and it worked fine.

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

Sidebar

Related Questions

I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext . I'm using
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext . These objects
I am using CoreData and have an Entity ContactList defined, which I created using
I'm using an NSFetchedResultsController in a standard way to update a UITableView whenever something
Have just started using Google Chrome , and noticed in parts of our site,
Have you guys had any experiences (positive or negative) by placing your source code/solution
In my core data model I have a Person entity that has a to
I have a table view that is managed by an NSFetchedResultsController. I am having
I have a Group entity which has many Item entities. An Item entity can

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.