Re: CoreData: How to alter attributes undoably?
Re: CoreData: How to alter attributes undoably?
- Subject: Re: CoreData: How to alter attributes undoably?
- From: Frank Illenberger <email@hidden>
- Date: Sat, 25 Jun 2005 21:25:10 +0200
Good idea, I tried this, but setPrimitiveValue:forKey: does also
register its change with the undo manager.
No, it doesn't.
Indeed, you are completely right. I tried it in a small dummy app.
There it works perfectly. But in my real app, I could narrow the
problem further down:
The problem seems to derive from the event before making the
attribute change that should not be undable. There I add the object
to a relationship. By doing this, the undo manager seems to make a
complete snapshot of all the object's attributes: By undoing this
relationship add, even all attribute changes that were done via
direct calls to setPrimitiveValue:forKey: are undone. If there is no
relationship action beforehand, the setPrimitive value never gets
undone as I wished.
So this seems to be a conceptual problem.
<http://developer.apple.com/documentation/Cocoa/Reference/
CoreData_ObjC/Classes/NSManagedObject.html#//apple_ref/doc/uid/
TP30001171-BBCEBFCH>
Have you overridden this method (setPrimitiveValue:forKey:), or are
you invoking the change notification methods before and after?
NSManagedObjectContext *moc = [self managedObjectContext];
[moc processPendingChanges];
[[moc undoManager] disableUndoRegistration];
[self setSomeAttribute:@"Some Value"];
[moc processPendingChanges];
[[moc undoManager] enableUndoRegistration];
This should work -- again what other methods are being invoked and
when?
mmalc
_______________________________________________
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