• 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
[Q]: Object ownership, undos, tableview, etc.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q]: Object ownership, undos, tableview, etc.


  • Subject: [Q]: Object ownership, undos, tableview, etc.
  • From: Joe Chan <email@hidden>
  • Date: Thu, 18 Oct 2001 14:19:56 -0400

I have a NSMutableArray of object that I keep in my model object. One of the operations that I would like to have undo/redo on are insertion and removal of objects from the array. For example, I have these methods:

- (void)insertItem: (id)item at: (int)pos;
- (void)removeItemAt: (int)pos;
- (id)itemAtIndex: (int)pos;

1. Looking at NSUndoManager, I can either use the simple undo or invocation base method. When a object is removed from the array (either by undoing or redoing an insertion), I would like to preserve that object and its index on the undo/redo stack. The natural question is that who should (or have already) retain(ed) the object? I read that the invocation based undo does not retain the argument object, but I'm not certain if the simple undo method does or not. In either case, someone will have to retain it before can be removed. What's the best way to do this?

2. Assuming that I'll have to use the simple undo method, and store the object reference and its index in a dictionary, and I have a limited level of undo. When an undo containing the dictionary gets dropped off from the undo stack, how do I release the dictionary object? If I don't need to explicitly release it, who does?

3. If I'm displaying this array of object is a NSTableView, one item per row, and I allow the user to select multiple rows and delete them, will all the removal be group together in one undo action? I know that as long as I remove from the bottom up, the order of insertion/removal will be consistent, but I want to make sure that I don't need to treat multiple removals differently than a series of single removals.

4. Is the customary method to update a NSTableView to send it a reloadData message? Can I update just one cell (for efficiency)?

-----------
Joe Chan
email@hidden
http://www.firstian.com


  • Prev by Date: Re: launchApplication (NSWorkSpace) : the icon is always displayed
  • Next by Date: Re: NSTableView and NSTextView
  • Previous by thread: Re: DV Capture
  • Next by thread: Re: [Q]: Object ownership, undos, tableview, etc.
  • Index(es):
    • Date
    • Thread