Question

My app performs certain actions in a method attached to the NSManagedObjectContextDidSaveNotification notification (which is being executed on save). It also uses an NSUndoManager which is undoing/redoing happily. I had expected the 'did save' notification to be raised whenever an undo or redo occurred (in cases where the undo/redo affected the Core Data repository), but that doesn't seem to be happening.

Is it reasonable to expect the NSManagedObjectContextDidSaveNotification to be posted for undo/redo? If not, is there a way we can determine what was undone/redone after the fact (NSUndoManagerDidUndoChangeNotification does not appear to expose that info)?

Was it helpful?

Solution

It seems I was mistaken in my assumption that undo/redo should have anything to do with saving the NSManagedObjectContext.

Because my app auto-saves, my beleaguered brain thought that the undo/redo would auto-save too. Clearly this is not so.

I'm now observing the NSUndoManagerDidUndoChangeNotification and NSUndoManagerDidRedoChangeNotification notifications and manually saving there which is (currently) giving me the behaviour I expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top