Search code examples
iosobjective-cmacoscore-datansundomanager

How to disable the NSUndoManager for certain actions/entities with CoreData?


I work with CoreData on OSX (but I guess the problem is the same for iOS).

I would like to disable the undo management for the creation/deletion of NSManagedObjects. But, if possible, I would to keep the undo management for the attributes (like NSStrings, etc.) of my entities.

How can I do that?

If possible, I would like a global solution, such as subclass MyManagedObjectof NSManagedObject with overwritten methods (awakeFromInsert, prepareForDeletion).


Solution

  • You can decide a associate no NSUndoManager to a NSManagedObjectContext :

        [self.managedObjectContext setUndoManager:nil] ;