CoreData: Clear changes from NSManagedObjectContext

You might be looking for -refreshObject:mergeChanges: - the docs say that it resets an object from the persistent store, and if you pass NO as the second argument, you can choose not to reapply changes that have been made.

This will likely require you to store a set of objects that you have changed (for the first argument), then clear that set when you commit changes in your context to the store. This should be a pretty trivial addition, though.


Swift 5

managedObjectContext.rollback()

NSManagedObjectContext has a simple method for this:

[managedObjectContext rollback];

This method "removes everything from the undo stack, discards all insertions and deletions, and restores updated objects to their last committed values." (documentation)

Unless I'm missing something, that should give you everything you need.