I am writing a NSPersistentDocument application. The managedDocumentContext of a newly created document should be populated with a root object but this creation should not be undoable by the user. Therefore I implemented initWithType:error: in NSPersistentDocument:
- (id)initWithType:(NSString *)typeName error:(NSError **)outError { self = [super initWithType:typeName error:outError]; if(self != nil) { NSManagedObjectContext *mc = [self managedObjectContext]; [[mc undoManager] disableUndoRegistration]; base = [[NSEntityDescription insertNewObjectForEntityForName:@"Base" inManagedObjectContext:mc] retain]; [base setTitle:[self displayName]]; [[mc undoManager] enableUndoRegistration]; } return self; }
But the undo manager seems to ignore that I disabled the undo registration while creating the base object: After the second click into the "Edit" menu, the "Undo" menu item is enabled and the user can undo the creation of the base object.
Is this a bug in Cocoa/CoreData or am I doing something wrong?
Regards
Frank
|