• 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: NSTreeController -removeObjectsAtArrangedObjectIndexPath: [solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController -removeObjectsAtArrangedObjectIndexPath: [solved]


  • Subject: Re: NSTreeController -removeObjectsAtArrangedObjectIndexPath: [solved]
  • From: Ben Lachman <email@hidden>
  • Date: Mon, 8 Oct 2007 15:34:09 -0400

After looking at this all morning and reading various docs, cocoa- dev, old posts, etc. I came up with a method that no one mentions, probably because it is so simple if you're using a coredata backing. All you do is use the basic removeObjectsAtArrangedObjectIndexPath: on the set of selection indexes and set the delete rule for your coredata object's child relationship to cascade deletes. Just make sure you commitEditing and rearrangeObjects on the tree controller and reloadData on the outline view after doing this. Another nice byproduct of this is that it gets rid of a bug where removed items come back if you rename another item in the outlineview (gosh I hate NSOutlineView/NSTreecontroller).

Hope this helps someone out.

->Ben
--
"Pinky, you've left the lens cap of your mind on again." - The Brain


On Oct 8, 2007, at 2:48 PM, Chris Williams wrote:

I don't know this method. I'm not sure what the docs mean by "indexPaths".

I'm doing much the same thing (removing a tree of items from a OutlineView)
with a small recursive function. To wit:


- (void)clearTree {
    int i;
    int kids = [self numberOfChildren];
    for (i=kids-1; i>=0; i--)
        [[self childAtIndex:i] clearTree];
    id tmp = [self children];
    if (tmp != IsALeafNode) [children release];
    children == NULL;
}

The asking the parent item to reload...


On 10/7/07 9:46 PM, "Ben Lachman" <email@hidden> wrote:

Is there a less complex work
around than going through the paths, and sorting them by length
(depth) and processing them in batches?


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: NSTreeController -removeObjectsAtArrangedObjectIndexPath: (From: Chris Williams <email@hidden>)

  • Prev by Date: Re: Saving to application support folder.
  • Next by Date: Re: Saving to application support folder.
  • Previous by thread: Re: NSTreeController -removeObjectsAtArrangedObjectIndexPath:
  • Next by thread: Re: NSTreeController -removeObjectsAtArrangedObjectIndexPath:
  • Index(es):
    • Date
    • Thread