• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Undomanager for custom object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undomanager for custom object?


  • Subject: Re: Undomanager for custom object?
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 14 Mar 2012 09:37:27 -0500

On 14 Mar 2012, at 5:26 AM, Luc Van Bogaert wrote:

> On 13 Mar 2012, at 22:07, Kyle Sluder wrote:
>
>> On Mar 13, 2012, at 1:49 PM, Luc Van Bogaert wrote:
>>
>>> Hi,
>>>
>>> In my document-based app, I am using NSDocument's NSUndoManager to implement undo/redo. As part of my document objects, I have to deal with a custom object, for which I would also like to implement undo/redo. I know NSResponder has undo/redo features, but how should I implement this for a custom object?
>>
>> Not sure what you're asking here. What is your custom object--a view, a controller, a model object? Should it use the same undo manager as all the other objects?
>
> I would like to implement undo/redo for a model object which in turn is also a ivar backed property of a document object. I'm already using the document's undo manager to undo/redo setting the model object property. Once the property is set, the application has features to change properties of the model object. I'm not sure how to implement undo/redo for the changes of the model object's properties and ivars.

I still don't fully understand your design.

Is your problem that you feel you can undo assignment at the top level (the document's to-one relationship to the model object), but not changes to attributes and relationships of the model object itself?

If the document/window controller did the changes to the attributes (undo is a user-level concept, so there has to be a controller somewhere in the chain leading up to it), you'd have the document's undo manager, and the controller could register the changes itself. (registerUndo… / prepareWithInvocationTarget:)

If the relationship to the model attributes is more complicated, then (1) it isn't in response to a user/controller event, and it shouldn't be undoable (undo is a user-level concept); or in some rare case, (2) you'll have to pass the controller or its undo manager down to the model object somehow, so it can do the registration.

I feel I'm being vague and obvious, but as I say, I don't quite get what you're trying to do.

	— F


_______________________________________________

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


References: 
 >Undomanager for custom object? (From: Luc Van Bogaert <email@hidden>)
 >Re: Undomanager for custom object? (From: Kyle Sluder <email@hidden>)
 >Re: Undomanager for custom object? (From: Luc Van Bogaert <email@hidden>)

  • Prev by Date: Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?
  • Next by Date: nil in cocoa collections
  • Previous by thread: Re: Undomanager for custom object?
  • Next by thread: Re: Undomanager for custom object?
  • Index(es):
    • Date
    • Thread