• 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: Undo in tables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo in tables


  • Subject: Re: Undo in tables
  • From: Brian Webster <email@hidden>
  • Date: Sun, 14 Apr 2002 12:55:20 -0500

On Sunday, April 14, 2002, at 12:04 AM, cocoa-dev-
email@hidden wrote:

If your table's records (rows) are objects, their previous
versions should therefore be held in the undo stack (by copying, not
retaining, because the value is different, right? -- I think I read
somewhere recently that they are copied).

Well, it depends on your implementation. If the action performed simply involves changing a property of the object, like a simple string, then there's no point in copying the entire previous version of the object - just keep a copy of the old value for that property. NSUndoManager doesn't copy anything, it just collects the arguments for the undo registration and tells the NSInvocation it stores it in to retain them. There might be some situations in which copying the whole object would be appropriate, though, like if an action performs some complex algorithm that can't be simply inverted.

When it comes to deleting objects, I usually just register the undo right before the deletion, so that the undo manager will retain the object first, at which point I can delete it from my collection but still have it hanging around in memory for potential reinsertion by an undo operation. It doesn't use up any more memory by making a copy of the object, it just retains it and reinserts it if necessary.

I think it would be clearer if Apple would specifically document that NSUndoManager does retain arguments for an undo action. I still haven't tested registerUndoWithTarget:selector:object: to see if it retains as well.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

  • Prev by Date: Re: Distorted System Sounds
  • Next by Date: Re: request to folks who read the digest version of this list
  • Previous by thread: Re: Undo in tables
  • Next by thread: [ANN] Some new Mulle stuff
  • Index(es):
    • Date
    • Thread