I am trying to migrate some code to use an NSManagedObjectContext
with NSPrivateQueueConcurrencyType
.
I\'m sometimes getting very odd error
The argument -com.apple.CoreData.ConcurrencyDebug
is available from iOS > 8 and OSX > 10.10 : make sure you target the right platform.
The console should log this if the flag is enabled :
CoreData: annotation: Core Data multi-threading assertions enabled.
Source : Core Data Concurrency Debugging from Ole Begemann
Working with XCode 8.x and iOS 10.x, I wanted to provide a streamlined answer for anyone wanting to implement this now.
You will first need to modify the scheme for your app:
Once you select Scheme, select Edit Scheme which should appear near the bottom of your list:
When opened, make sure that you have Run selected and choose Arguments. You will want to copy the following values in:
-com.apple.CoreData.ConcurrencyDebug 1
-com.apple.CoreData.Logging.stderr 1
Your screen should look like this:
After launching the app, you should see this appear in your console now when those options are enabled:
CoreData: annotation: Core Data multi-threading assertions enabled.
And when you run into an exception generated by this, you will likely see this:
CoreData`+[NSManagedObjectContext Multithreading_Violation_AllThatIsLeftToUsIsHonor]:
You can return to the scheme editor and disable this logging as needed to prevent exceptions in the future.