Sorry, you cannot find around _nilOutReservedCurrentEventSnapshot__
online ..
This is likely due to the life cycle of the snapshot of the managed entity.
When Core Data retrieves an object from persistent storage, it receives a snapshot of its state. A snapshot is a dictionary of the permanent properties of objects, as a rule, of all its attributes and global identifiers of any objects to which it has a "one" relationship. Pictures participate in optimistic blocking. When the wireframe saves, it compares the values ββin each image of the edited objects with the current corresponding values ββin the persistent storage.
The fact that _nilOutReservedCurrentEventSnapshot__
not documented means that this type of behavior should not be.
We know that this is a function of the NSManagedObject
class.
Therefore, the error unrecognized selector sent to instance
was caused by the fact that _nilOutReservedCurrentEventSnapshot__
was called on an object that was not NSManagedObject
, because NSManagedObject
was freed, and now something else fills its memory. It is a fact.
The context is not indicated in the question about the nature of the application and its configuration of CoreData, but it is assumed that it uses the parent-child concurrency template. It is important.

[Image retrieved from here ]
Of all the questions asked during stack overflow that I can find about this error, it seems that they all use the parent-child concurrency pattern.
It is possible that the problem was caused by the adoption of this template with improper implementation or processing of ManagedObjects.
A A situation in which a parent-child context can be used is the synchronization of cloud data or the processing of changes made when a user edits something with the ability to undo or undo changes made that can be made in the background thread.
The question also mentions that this is a rare occurrence and does not occur every time. This means that the contexts are probably fine until a certain save or change occurs, and somehow the contexts cease to synchronize, and performing another save will cause the application to crash.
In the documents Synchronization of changes between contexts:
If you use more than one managed object context in an application, Core Data does not automatically notify one context of changes made by objects in another. In general, this is because the context is intended to create scratches, where you can make changes to objects in isolation, and you can undo changes without affecting other contexts.
Changes will be sent to the parent context when the child is saved, but not if the parent has been changed separately. It is highly recommended that you never change the parent context; only by preserving the childish context and spreading the changes from there.
Possible cause of failure
There are a few things that can cause this, but two that stick out:
1. Release ManagedObject from the link, which is removed due to a rejection of the modal view in the application or iOS sheet in the OSX application.
possible solution: set the retainsRegisteredObjects
property of the child context to true
before retrieving ManagedObjects (and then set it to false as soon as the contexts are saved to avoid further potential memory leaks). a warning!
eg. ctx.retainsRegisteredObjects = true
2. Raw changes in context.
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/ChangeManagement.html#//apple_ref/doc/uid/TP40001075-CH22-SW1
Consider an application with two contexts of managed objects and one permanent repository coordinator. If the user deletes the object in the first context (moc1), you may need to inform the second context (moc2) that the object was deleted. In all cases, moc1 automatically sends an NSManagedObjectContextDidSaveNotification notification through the NSNotificationCenter, which your application must register and use as a trigger for any action that needs to be taken. This notification contains information not only about deleted objects, but also about changed objects. You need to process these changes because they may be the result of deletion. Most of these types of changes are related to transitional relationships or derived properties.
Possible solutions:
Since there is no other information to deduce what causes the error, and I cannot reproduce it .. I would suggest trying to find where your ManagedObject
freed using Zombie profiling in tools.
If a message is sent to one of these freed objects (which are now NSZombie objects), a zombie sign is placed, the application crashes, recording stops and the Zombie Messaged dialog box appears. You can then study the history of saving and freeing a zombie object to pinpoint where the problem arose.
https://github.com/iascchen/SwiftCoreDataSimpleDemo/blob/master/SwiftCoreDataSimpleDemo/CoreDataHelper.swift
Hopefully then someone can shed light on what caused the problem.
in +++++++++++++++++++++++++++++++++++
Side note:
parent / child contexts can lead to stuttering from the user interface - "every request for selection, and each save operation completely blocks the main stream when data is read or written to / from the disk." This is because each selection is pulled through the parent context (in the main thread) for the child.
SO response support
It is recommended that if you use this approach, you will rethink the project as something like two independent contexts of managed objects associated with the same permanent repository coordinator , which may "avoid" the problem in the future in the future.
[Image retrieved from here ]
You can see dramatic performance differences in a related article