Best Practice for implementing NSUndoManager?
Best Practice for implementing NSUndoManager?
- Subject: Best Practice for implementing NSUndoManager?
- From: Luke Tupper <email@hidden>
- Date: Tue, 8 Jun 2004 20:38:01 +1000
Hi,
I am slowly learning cocoa and have been working through a fairly
basic project, which at its essence is a table view that manipulates
an array of data. While I haven't found the description of how to do
many things in cocoa to hard to grasp (things like populating and
sorting tables, saving files etc) I did find that the information
about implementing undo to be rather sparse. Now that I have
implemented undo within my app it is really easy, however I found
very little in terms of detailed implementation information either
online or in a variety of cocoa books. The examples I did find where
often quite complicated apps such as the sketch sample app.
As I said I have implemented undo within my app but I have two questions:
1) Should the model or the controller add objects to the undo
manager? Currently I have the model objects making calls to the undo
manager. This seems to be the most flexible approach especially when
you have to manipulate a large number of the model objects at once.
2) If I am on the right track with question 1, then question 2 is:
How should you propagate the NSUndoManager within the app? At present
I am passing the NSUndoManager to objects during the initialization
of the object, is there an easier or more elegant way to do this?
If my descriptions of my application don't make much sense I have
created a simple sample application (simple table with amount and
description fields, and a couple of buttons to add, delete and
multiply the values of records). If you want to have a look it is
available online here:
http://www.tupps.com/cocoa/undoexample.sitx
If I can work out a 'decent' (I understand there is no perfect
solution) solution to implementing NSUndoManager then I will put a
description around the sample undo application I have made and will
write a little bit of info about it so other newbies will hopefully
have an easier time with it.
Thanks
Luke
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.