I am trying to migrate some code to use an NSManagedObjectContext
with NSPrivateQueueConcurrencyType
.
I'm sometimes getting very odd errors after saving the context to its parent, and then saving the parent. I'm wondering if these are due to be not using the NSPrivateQueueConcurrencyType
context correctly.
I've turned on -com.apple.CoreData.ConcurrencyDebug 1
to try to debug this. I'm pretty sure that this is not working however. If I perform operations on managed object context or change its objects without using performBlock:
, I don't get an error or a throw.
Here's how I've set up the scheme's arguments:. I've also tried it without the leading -
.
Any idea what I'm doing wrong?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With