I am trying to observe individual NSManagedObject
changes on NSManagedObjectContextWillSaveNotification
:
- (void)managedObjectContextWillSave:(NSNotification *)notification
{
for (NSManagedObject * object in self.mutableObservedManagedObjects)
{
if (object.hasChanges)
{
[self managedObjectWasUpdated:object];
}
}
}
The problem is that hasChanges
is true while object.changedValues
is empty, thus wrongly (?) triggering managedObjectWasUpdated:
.
I'm trying to understand why this is the case and if I should better check object.changedValues.count
before calling managedObjectWasUpdated:
.
isInserted
and isDeleted
are both false.
I encountered the same issue. Instead of getting the flags, I just checked if changedValues() is empty.
For Swift:
if !managedObject.changedValues().isEmpty {
// Has some changed values
}