开发者

Getting Serious Application Error With Core Data

I got the following error when deleting an object from my app. Any ideas on how to fix it?

I'm still trying to recreate the process to find out exactly where it is crashing.

Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  CoreData could not fulfill a fault for '0x5adc8b0 <x-coredata://2B90C6EC-E046-4508-A1B1-6C4B19BF830D/Session/p1>' with userInfo {
NSAffectedObjectsErrorKey =     (
        "<Session: 0x6f7c830> (entity: Session; id: 0x5adc8b0 <x-coredata://2B90C6EC-E046-4508-A1B1-6C4B19BF830D/Session/p1> ; data: <fault>)"
    );
*** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x5adc8b0 <x-coredata:/开发者_C百科/2B90C6EC-E046-4508-A1B1-6C4B19BF830D/Session/p1>''


A) If you are subscribing to save notifications, Core Data is pointing to a failure there.

B) The "could not fulfill a fault" message is often related to deleting an object, after which some other part of your app tries to access ANY property on it. Yes, even ones where faults were previously fulfilled. The whole object is unusable after a delete.


This occurred in my code when I passed a managed object down to a custom NSOperation class. My NSOperation would load other objects through its to-many relationship, process them, then delete those objects. If it tried to do a search on more objects in the to-many relationship, it would sometimes crash with the "CoreData could not fulfill a fault" exception. Then I remembered reading about "thread confinement" in the Core Data Programming Guide so I changed my code to pass a key down to my NSOperation class. The NSOperation class would then do its own search in its own context to find its own instance of the core data class. I stopped getting the exception after that. (I still have to use save notifications.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜