Search code examples
ioscore-datafaultmagicalrecord

How to find a "CoreData could not fulfill a fault" Exception


I am using MagicalRecord to handle all my CoreData Stuff that's going on and NSFetchedResultsControllers to display the data in TableViews and CollectionViews.

The problem is, that somewhere in my app, I seem to have a problem with a "CoreData could not fulfill a fault" Exception.

Is there a solution to set a breakpoint to this part of my app? The main problem I have, is that it's crashing and I have no idea where to find it! The "All Exception" breakpoints doesn't seem to help...

Btw. I am not retaining any managedObjects... That makes it even more weird for me...

Any help is appreciated


Solution

  • This error happens when your code (or MagicalRecord) retains an object that is deleted by CoreData in a managed object context, usually on another thread. I would make sure I am not storing temporary objects or objects that may be deleted as properties, in collections, etc. Because you mentioned you don't, I would make sure I don't have threading code that might be out of sync, and ultimately, I would make sure MagicalRecord doesn't have some threaded background deletes or faux garbage collection for the one-to-many relationship classes or something of that sort that could be causing the issue.

    As a solution you could check for fault objects manually to avoid the crashes. Look at this question for ways to do that: How can I tell whether an `NSManagedObject` has been deleted?

    Sorry if this is too generic, but without seeing your application it is hard to say why exactly you are getting the error.