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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:18:14+00:00 2026-06-10T12:18:14+00:00

I have an NSManagedObject entity which override validateForInsert and validateForUpdate. This methods return NO

  • 0

I have an NSManagedObject entity which override validateForInsert and validateForUpdate.

This methods return NO correctly when something is wrong in object consistency, based on some logic I wrote.

The application is a classic uitableview backed by an NSFetchedResultsController, with a detail view controller.

When I add a new entity the detail view controller is instantiated with a nil objectID, and pushed into the navigation stack.
When I pop the detail controller the [context save:&error] is called, and by putting some breakpoint I discovered that the fetched delegate method are fired once when I add a new entity, even when the validateForInsert return NO, and includePendingChanges is set to NO too.

When I retry to pop again the detail controller, the save is of course invoked again, the validate method too, but this time the NSFetchedResultsControllerDelegate are not fired.

I would like to know if this is normal behavior, or if I am missing something in my model.

[UPDATE]

This the stack trace after a breakpoint in delegate methods:

#0  0x0003e5ba in -[MyTableViewController controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:] at ......
#1  0x011512f9 in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] ()
#2  0x00b46a29 in __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 ()
#3  0x01759855 in ___CFXNotificationPost_block_invoke_0 ()
#4  0x01759778 in _CFXNotificationPost ()
#5  0x00a8b19a in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#6  0x0106a673 in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] ()
#7  0x01101f5e in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] ()
#8  0x01065ad3 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] ()
#9  0x0106916b in -[NSManagedObjectContext save:] ()
#10 0x00004490 in -[MyAppDelegate saveContext:]

It can be seen that the validate is not called, even though the save is invoked on context, and this therefore make the fetched controller delegate to be fired.

[UPDATE 2]

In particular, don’t know if it is related, this is causing an exception (not always) in controllerDidChangeObject:

CoreData: error: Serious application error. An exception was caught
from the delegate of NSFetchedResultsController during a call to
-controllerDidChangeContent:. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section
after the update (4) 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 (0 inserted, 0 deleted) and plus
or minus the number of rows moved into or out of that section (0 moved
in, 0 moved out). with userInfo (null)

and infact in the origin table has three rows, just because the context bypass the validateFor methods when object is created in context seems that a row is inserted, there is inconsistency in rows number.

The controller delegate are quite simple and standard:

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

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
   // for testing purpose I am not doing any modification
   return;
}

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

Still I don’t know who is updating the table view

  • 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-10T12:18:16+00:00Added an answer on June 10, 2026 at 12:18 pm

    I think this is normal behaviour; the fetched results controller doesn’t require a save before it shows changes. If you don’t want the changes made in your detail view to appear in the master before they’re saved, you’ll have to make a separate NSManagedObject context for the detail view. That way, only objects that are saved to the persistent store will make it back to the fetched results controller.

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

Sidebar

Related Questions

I have a few entities which are managed by custom NSManagedObject classes. They are
I'm facing something mysterious. I have a boolean property on an NSManagedObject subclass ReinspectionTask.
I have the following core data model with two entities: entity item which holds
I have an entity class called catObras, and it inherits from the class NSManagedObject.
I have an 3 object hierarchy which has a root as 'Division' that has
I have a Person entity which belongs to a Department in a one to
I have a Core Data model similar to this: Company Entity companyName attribute (string)
I have a class, Song, which subclasses NSManagedObject. I'm using GDB to try and
I have a category for each of my NSManagedObject subclasses, where factory methods sit,
I have a custom NSManagedObject which has several properties. I alloc and init two

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.