Re: NSTreeController, Core Data and root objects
Re: NSTreeController, Core Data and root objects
- Subject: Re: NSTreeController, Core Data and root objects
- From: Steve Steinitz <email@hidden>
- Date: Fri, 6 Nov 2009 08:35:20 +1100
Hi Rob,
On 5/11/09, Rob Keniger wrote:
as I add a new item to the top level it fails because the tree
controller does not assign the "invisible" root item as the
parent of the new item.
Fritz's idea looks much cooler (I might try it) but for a
clumsier solution, have you written your own method to add new
top-level items? I wonder if an IBAction like this would work:
- (IBAction)
addVisibleTopLevelItem: sender
{
YourEntity *invisibleTop = [self topObject];
YourEntity *newVisibleTop =
[NSEntityDescription insertNewObjectForEntityForName: @"YourEntity"
inManagedObjectContext: [context]];
[newVisibleTop setParent: invisibleTop]; // does your
entity have a setParent?
// might also need to add a child to inVisibleTop
[treeController addObject: newVisibleTop];
[treeController rearrangeObjects]; // needed?
}
Something along similar lines seems to work for me.
Cheers,
Steve
_______________________________________________
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