Core data context.hasChanges crash the app

Hello

I'm using core data in my app. I check debug argument "-com.apple.CoreData.ConcurrencyDebug 1".

Since I check it my app start crashing when I touch context peroperty "has changes".


More information you can see here https://stackoverflow.com/questions/61972247/core-data-crash-with-method-haschanges


Can you answer is the "hasChanges" property are not thread safe and I need wrap it by method "perform" or "performAndWait" ?

Answered by Frameworks Engineer in 612841022
You must be executing in the context of, well, a context (NSManagedObjectContext). So yes, you must do a -[NSManagedObjectContext performBlock:] or -[NSManagedObjectContext performBlockAndWait:].
Accepted Answer
You must be executing in the context of, well, a context (NSManagedObjectContext). So yes, you must do a -[NSManagedObjectContext performBlock:] or -[NSManagedObjectContext performBlockAndWait:].
As dstites noted, this method must be executed within the lexical scope of one of the perform methods. There are very few exceptions, so you should assume nothing is safe by default

Core data context.hasChanges crash the app
 
 
Q