首页 > 解决方案 > 无法从此 NSManagedObjectContext 的协调器访问对象的持久存储

问题描述

我在 iOS 12.0.1 上有以下崩溃日志:

Object's persistent store is not reachable from this NSManagedObjectContext's coordinator
Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1dae1bef8 __exceptionPreprocess
1  libobjc.A.dylib                0x1d9fe9a40 objc_exception_throw
2  CoreData                       0x1dda6f828 _PFRetainedObjectIDCore
3  CoreData                       0x1dd9a3238 -[NSManagedObjectContext objectWithID:]

如果我不重置持久存储,这怎么可能?

标签: ioscore-data

解决方案


Found your question and it is 100% similar to the crash I'm observing but have no idea how it might be fixed. The object is accessed from the main tread while it estimates the cells heights on the device rotation. I think that might be happening when the app is going to the background.

2 CoreData _PFRetainedObjectIDCore
3 CoreData -[NSManagedObjectContext objectWithID:]
4 CoreData _faultBatchAtIndex
5 CoreData -[_PFBatchFaultingArray retainedObjectAtIndex:]
6 CoreData -[_PFBatchFaultingArray objectAtIndex:]
7 CoreData -[NSFetchedResultsController objectAtIndexPath:]

9 UIKitCore -[UITableView _estimatedHeightForRowAtIndexPath:]
10 UIKitCore __66-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]_block_invoke
11 UIKitCore -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]
12 UIKitCore -[UITableViewRowData numberOfRows]
13 UIKitCore -[UITableView noteNumberOfRowsChanged]
14 UIKitCore -[UITableView reloadData]

推荐阅读