• 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
Handling Undo in a Non-Document app with "generational" objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling Undo in a Non-Document app with "generational" objects


  • Subject: Handling Undo in a Non-Document app with "generational" objects
  • From: Paul Bruneau <email@hidden>
  • Date: Tue, 7 Aug 2007 12:06:19 -0400

Hi,

I have a class called OrderStep whose objects represent the steps of an order.

Each of these objects has an NSMutableArray as an instance variable (nextSteps) whose purpose is to optionally hold more OrderStep objects, which can then optionally hold their own child objects, and so on.

orderStepA ---> orderStepB ---> orderStepE
                orderStepC
                orderStepD ---> orderStepF
                                orderStepG

You get the idea.

So I have a -deleteStep method which recursively calls itself for any objects in its nextSteps array before removing itself from the array of its parent object. This is working very well as far as memory management and overall operation.

But I want to implement Undo for it. My question is, how best to get my NSUndoManager to these objects so they can call prepareWithInvocationTarget? I feel like I am violating MVC because it seems like my model objects are going to have to know about the controller where the NSUndoManager object is stored. That doesn't seem right to me because the -deleteStep method could be called from really anywhere in the app.

For similar reasons, I don't think that using the - windowWillReturnUndoManager delegate will help me because my orderSteps aren't going to know what window they are in, right?

I think I know that in a design where there weren't these recursive children, I could just handle it all from the controller, but this thinking doesn't seem to fit given my situation. I don't think I can delete all the generations of children from the controller, and it is certainly easy to do it from each successive parent model object.

I am sure I am just thinking about something altogether wrong and I hope someone can give me a shove in the right direction.

Thank you
_______________________________________________

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


  • Follow-Ups:
    • Re: Handling Undo in a Non-Document app with "generational" objects
      • From: "Raphael Sebbe" <email@hidden>
  • Prev by Date: Re: Integrating Unix scripting in Cocoa app
  • Next by Date: How to identify root volume
  • Previous by thread: Re: ScreenSaver Shell?
  • Next by thread: Re: Handling Undo in a Non-Document app with "generational" objects
  • Index(es):
    • Date
    • Thread