Multiple NSManagedObjectContexts in one expression NSPersistentStoreCoordinator throws 'still active' exception

I am changing the CoreData setting to 2 NSManagedObjectContextbelow 1 NSPersistentStoreCoordinator.

  • The root context NSManagedObjectContext created with NSPrivateQueueConcurrencyTypeand setNSMergeByPropertyStoreTrumpMergePolicy
  • The main context NSManagedObjectContext created by using NSMainQueueConcurrencyTypeis also set toNSMergeByPropertyStoreTrumpMergePolicy

Both of them are not related by the parent-child relationship, but they are assigned the same object NSPersistentStoreCoordinator. The main context listens for the Root Context notification NSManagedObjectContextDidSaveNotificationand performs the necessary merge insideperformBlock:

Sometimes, when an instance is NSFetchedResultsControllerconnected to the Main Context , does performFetchI get

The application terminated due to the uncaught exception "NSInternalInconsistencyException", reason: "the instruction is still active"

I am wondering if I need to do what I am doing here or the Core Data limitation.

thanks

+4
source share
1 answer

Florian Kugler wrote a good article about this: Parallel Main Data Stack

The idea is to import your data in the context of a private queue ( Import Context ), which is a child of the Main Context .

( UI-), ( ) .

, - , . , , .

[ ], , . , . .

. , , , .

+4

Source: https://habr.com/ru/post/1607601/


All Articles