Coredata - “NSObjectInaccessibleException - CoreData could not fulfill a fault”

前端 未结 4 681
无人及你
无人及你 2021-01-30 21:39

I am new to Core data and still figuring out the nuts and bolts and this error has been bugging me for hours and I cant seem to find a solution. Any help is greatly appreciated.

相关标签:
4条回答
  • 2021-01-30 22:24

    I just resolved this error in my code. Seems my cache was corrupted in some way. I used Christopher Pickslay & Keil Gillard's suggestion of deleting or renaming my cache, and voila, crash resolved. NSFetchedResultsController index beyond bounds

    0 讨论(0)
  • 2021-01-30 22:33

    The reason removing your delete code makes it work is because you are removing the data in the persistent store without updating the other view that still has managed object instances tied to that data still in memory. Remember, while Core Data deals with objects, each object has to have a row in the database behind it. When you delete that row, Core Data gets angry.

    So, to fix this problem, and still delete your data, you should have your views listen for NSManagedObjectContextWillSaveNotification and/or NSManagedObjectContextDidSaveNotification notifications and update your views with the most up to date versions of data in your store. It is at this point you should throw away any Core Data objects your views are holding onto, and reload them from the store.

    0 讨论(0)
  • 2021-01-30 22:33

    For info, yesterday, I had the same error. I checked in a live version of the app, and it was still there. yikes.

    I ran through all the permutations of adding info to the core data stack until the crash occurred.

    I then looked at the sqlite file from the app in the simulator library using SqliteManager. I found a data error in one table. This had occurred as there is a starter db used the first time the app was run. The error was in the starter db.

    Ran the app again, testing each field in each table. Found several more occurrences. I remember reading this question, and thought maybe someone else could benefit from my mistake.

    0 讨论(0)
  • 2021-01-30 22:37

    Your over releasing fetchedObjects in your readFromCoreData method. executeFetchRequest will return to you autoreleased objects anyway. When the current run loop finished executing (when you're jumping from views) then it attempt to release the objects twice (assuming you haven't used your own autorelease pools).

    I'd change

    return [fetchedObjects autorelease]; 
    

    to

    return fetchedObjects;
    
    0 讨论(0)
提交回复
热议问题