Core Data validation errors appearing twice, multiple times
Stupid thing really. I’m using validation in Core Data for the first time. I have a managed object, it fails validation, which is good. I fix it, and save again. There should be no validation errors. But there are. Why?
The original, failed, managed object, is still in the managed object context. So even though my newly created second object passes validation, the other invalid one is still in there, trying to be saved, constantly failing.
I needed to
[moc deleteObject:oldObject]; and then it worked.
It’s a simple mistake. Trying to search for terms like “too many validation errors second time” and “Core Data reset validation” didn’t work, because that’s not actually what I was trying to do.
It was after successfully trying out
NSManagedObject reset that I realised what the problem was.