Re: NSTreeController -removeObjectsAtArrangedObjectIndexPath: [solved]
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