• 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
Undo logic location?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Undo logic location?
      • From: Jim Correia <email@hidden>
References: 
 >How Do I Flip An NSScrollView? (From: Dan Saul <email@hidden>)
 >Re: How Do I Flip An NSScrollView? (From: David Jeffery <email@hidden>)

  • Prev by Date: Re: How Do I Flip An NSScrollView?
  • Next by Date: Re: Defining Accessors in a Custom Palette for a NSArray for Cocoa Bindings
  • Previous by thread: Re: How Do I Flip An NSScrollView?
  • Next by thread: Re: Undo logic location?
  • Index(es):
    • Date
    • Thread