Clearing undo & dirty state in NSPersistentDocument
Clearing undo & dirty state in NSPersistentDocument
- Subject: Clearing undo & dirty state in NSPersistentDocument
- From: Rick Mann <email@hidden>
- Date: Wed, 04 Jan 2012 17:14:52 -0800
I have two different NSPersistentDocument subclasses. After a singleton of one is created, I call a temporary method to pre-populate it with test data, and then call the following code to save the data and clear the undo & dirty state:
NSManagedObjectContext* moc = self.managedObjectContext;
NSError* err = nil;
bool success = [moc save: &err];
if (!success)
{
NSLog(@"Error saving test part defs: %@", err);
}
[moc processPendingChanges];
[moc.undoManager removeAllActions];
[self updateChangeCount: NSChangeCleared];
However, this does not work. I can still undo in the document, and if I try to close it, it asks to save (and the close button has a dot).
However, I do the same thing in my other document subclass, inside -initWithType:error: (although I don't call -save:), and it works as expected.
Any ideas what might be going on?
Thanks,
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden