문제

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).

도움이 되었습니까?

해결책 2

You can decide a associate no NSUndoManager to a NSManagedObjectContext :

    [self.managedObjectContext setUndoManager:nil] ;

다른 팁

NSUndoManager has disableUndoRegistration and enableUndoRegistration methods to allow this. You need to intercept the operations that you don't want to be undoable and disable/enable the undo manager as appropriate. Note that calls to enable and disable must balance (don't call one without also calling (or having called) the other. It is also your responsibility to ensure that undoing any operation doesn't result in invalid state (this is the purpose of beginUndoGrouping).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top