Making com.apple.CoreData.ConcurrencyDebug 1 work

后端 未结 2 1567
长发绾君心
长发绾君心 2020-12-15 10:16

I am trying to migrate some code to use an NSManagedObjectContext with NSPrivateQueueConcurrencyType.

I\'m sometimes getting very odd error

相关标签:
2条回答
  • 2020-12-15 10:41

    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

    0 讨论(0)
  • 2020-12-15 10:52

    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.

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