Re: Temporarily disabling Undo Registration with Core Data
Re: Temporarily disabling Undo Registration with Core Data
- Subject: Re: Temporarily disabling Undo Registration with Core Data
- From: John Timmer <email@hidden>
- Date: Wed, 25 May 2005 17:26:59 -0400
I was seeing this behavior in my app, and it was driving me nuts until I
asked an unrelated question and mmalc suggested using the
"processPendingChanges" method to ensure that the creation of the new object
propagated into the undo manager before you tried to clear things. Ending
your method with:
[[self managedObjectContext] processPendingChanges];
[[[self managedObjectContext] undoManager] removeAllActions];
Should get things to work as expected - no need for disabling and enabling
registration. Worked for me, at least.
JT
> I have a Core-Data Document app that I am trying to have instantiate
> an object when opening a new document. I have gotten this part to
> work by checking for this objects existence during awakeFromNib by
> using executeFetchRequest; If the object does not exists, then I
> create one using insertNewObjectForEntityForName. This works fine
> with the exception that it dirties the document, and can be
> "Undo"ne. I have tried various combinations of the following:
>
> - (void)awakeFromNib
> {
> ... (some code) ...
> [[[self managedObjectContext] undoManager]
> disableUndoRegistration];
> [NSEntityDescription insertNewObjectForEntityForName:@"obj"
> inManagedObjectContext:[self managedObjectContext]];
> [[[self managedObjectContext] undoManager] enableUndoRegistration];
> [[[self managedObjectContext] undoManager] removeAllActions];
> }
>
> If I only disableUndoRegistration, then nothing is ever "Undo"able,
> but if I do both disableUndoRegistration and enableUndoRegistration
> (or use removeAllActions), then the first new document shows up as
> clean until I click on the window, anywhere, then it dirties and is
> "Undo"able, all additional documents are dirty immediately.
_______________________________________________
This mind intentionally left blank
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden