Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
- Subject: Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
- From: Mike Abdullah <email@hidden>
- Date: Mon, 28 Jun 2010 11:33:55 +0100
On 27 Jun 2010, at 00:01, Guillaume Laurent wrote:
> Hi all,
>
> I'm having difficulties with the undo/redo mechanism and my Core Data objects. The problem is that I create a CoreData object (say a rectangle), then set some of its attributes according to some controls values (the position and size of a CALayer the user has just created in a view). This set of actions is a single one from the user's point of view. I know I can make it appear so with NSUndoManager:beginUndoGrouping/endUndoGrouping. But when I undo this in the app, each of the steps of the object's creation are undone seperately, including the setting of each of the attributes.
Alarm bells going off here. Even if Core Data wasn't coalescing these changes into one undo operation, NSUndoManager should do it for you with the groups-by-event behaviour. Have you turned this off by any chance?
>
> This wouldn't be much of a problem in itself but it does make much more complex the observing of the object's attributes, which I require to maintain the consistency of the relationship between the CoreData rectangle and the CALayer representing it.
>
> Bottom line : is there a way to make it so that the CoreData object's instantiation and its setup are registered as a single action in the undo/redo stack ? So that instead of having
>
> - new rect with rect.x = 0
> - rect.x change from 0 to 100
>
> I can have
>
> - new rect with rect.x = 100
>
> ?
>
> Thanks for any replies,
>
> --
> Guillaume
> http://telegraph-road.org
>
>
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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