Undo logic location?
Undo logic location?
- Subject: Undo logic location?
- From: Tom Davies <email@hidden>
- Date: Thu, 6 Jan 2005 17:51:37 +1100
My App has this sort of structure:
MyDocument has-a Catalogue (my model class) which contains an
NSMutableArray
MyDocument.nib contains an NSArrayController whose contentArray is
bound to MyDocument.catalogue.definitionItems and an NSTableView whose
content is bound to the NSArrayController.
This all works fine, but I'm not sure where to put my undo logic. At
the moment I have this method in Catalogue (inspired by Hillegass):
- (void)removeObjectFromDefinitionItemsAtIndex:(int)index
{
DefinitionItem* d = [definitionItems objectAtIndex:index];
// add inverse of operation to undo stack
NSUndoManager* undo = [owner undoManager];
[[undo prepareWithInvocationTarget:self] insertObject:d
inDefinitionItemsAtIndex:index];
if (![undo isUndoing])
{
[undo setActionName:@"Delete Definition Item"];
}
[owner stopObservingDefinitionItem:d];
[definitionItems removeObjectAtIndex:index];
}
and I set the owner of the Catalogue to the MyDocument instance, but
I'd rather not have undo logic in my model at all.
1. Where does the undo logic belong?
2. How does wherever it goes observe the changes to the definitionItems
array?
Thanks for any ideas,
Tom
--
email@hidden
_______________________________________________
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