0

I have a very odd error with Core Data. I have a Recipe class that has a many to many relationship to an Ingredient class.

When I try to add an Ingredient to the Recipe on a RecipeViewController, everything works fine until I save the context. Thats when things go horribly wrong.

I get an error on my RecipesTableViewController (which has a NSFetchedResultsController and implements NSFetchedResultsControllerDelegate). The

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller

method gets called and then I get an exception:

CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. -[KCGIngredient sectionOffset]: unrecognized selector sent to instance 0x7bf83d50 with userInfo (null)

I have no idea what this sectionOffset message is and couldn't find it in the documentation. This happens after NSFetchResultsController gets the _postprocessInsertedObjects: message.

I'm assuming this sectionOffset message was intended to an instance of NSFetchedResultsController, but I have no idea how it ended up being sent to a model object.

EDIT:

Actually, I checked it out and apparently sectionOffset is not a method of NSFetchedResultsController.

This test fails miserably:

XCTAssertTrue([NSFetchedResultsController instancesRespondToSelector:@selector(sectionOffset)]);

What on Earth is going on? I already tried everything,s o if you can shed some light, I'd really appreciate it.

jww
  • 97,681
  • 90
  • 411
  • 885
cfischer
  • 24,452
  • 37
  • 131
  • 214
  • This kind of error is often an indication that an object has been deallocated and different class of object created (coincidentally) in its place. One way to debug this is to "turn on zombies". If you search on this phrase you will find various questions and answers which might help you to pin down the problem. – pbasdf Apr 23 '15 at 20:24
  • Is `sectionOffset` a method on `KCGIngredient`? – Tom Harrington Apr 23 '15 at 20:38
  • @TomHarrington Absolutely not. That's why I'm getting the unrecognized selector exception. I implemented a stub for ```sectionOffset```just to see what happens, but I just get sent another method that ```KCGIngredient```doesn't understand either. – cfischer Apr 23 '15 at 20:51
  • @pbasdf Zombies didn't help either. I just get the error right after ```NSFetchResultsController``` gets the ```_postprocessInsertedObjects:``` – cfischer Apr 23 '15 at 20:53
  • Can you post the code where you set up the FRC, and its delegate methods? Thanks. – pbasdf Apr 23 '15 at 21:09

0 Answers0